%%%调入幅值数据文件
X=load('F1shuju-幅值.txt');
n=length(X);
F=importdata('时间和循环次数 f1-改正版.txt');
for i=1:n
x=X(i,2);
%定义循环次数与时间关系的分段函数
if (F(1,1)<=x) &&(x<=F(2,1))
y=x/(F(2,1)-F(1,1))*(F(2,2)-F(1,2));
else if (F(2,1)<=x) &&(x<=F(3,1))
y=(x-F(2,1))/(F(3,1)-F(2,1))*(F(3,2)-F(2,2))+F(2,2);
else if (F(3,1)<=x) &&(x<=F(4,1))
y=(x-F(3,1))/(F(4,1)-F(3,1))*(F(4,2)-F(3,2))+F(3,2);
else if (F(4,1)<=x) &&(x<=F(5,1))
y=(x-F(4,1))/(F(5,1)-F(4,1))*(F(5,2)-F(4,2))+F(4,2);
else if (F(5,1)<=x) &&(x<=F(6,1))
y=(x-F(5,1))/(F(6,1)-F(5,1))*(F(6,2)-F(5,2))+F(5,2);
else if (F(6,1)<=x) &&(x<=F(7,1))
y=(x-F(6,1))/(F(7,1)-F(6,1))*(F(7,2)-F(6,2))+F(6,2);
else if (F(7,1)<=x) &&(x<=F(8,1))
y=(x-F(7,1))/(F(8,1)-F(7,1))*(F(8,2)-F(7,2))+F(7,2);
else if (F(8,1)<=x) &&(x<=F(9,1))
y=(x-F(8,1))/(F(9,1)-F(8,1))*(F(9,2)-F(8,2))+F(8,2);
else if (F(9,1)<=x) &&(x<=F(10,1))
y=(x-F(9,1))/(F(10,1)-F(9,1))*(F(10,2)-F(9,2))+F(9,2);
else if (F(10,1)<=x) &&(x<=F(11,1))
y=(x-F(10,1))/(F(11,1)-F(10,1))*(F(11,2)-F(10,2))+F(10,2);
else if (F(11,1)<=x) &&(x<=F(12,1))
y=(x-F(11,1))/(F(12,1)-F(11,1))*(F(12,2)-F(11,2))+F(11,2);
else if (F(12,1)<=x) &&(x<=F(13,1))
y=(x-F(12,1))/(F(13,1)-F(12,1))*(F(13,2)-F(12,2))+F(12,2);
else if (F(13,1)<=x) &&(x<=F(14,1))
y=(x-F(13,1))/(F(14,1)-F(13,1))*(F(14,2)-F(13,2))+F(13,2);
else if (F(14,1)<=x) &&(x<=F(15,1))
y=(x-F(14,1))/(F(15,1)-F(14,1))*(F(15,2)-F(14,2))+F(14,2);
else if (F(15,1)<=x) && (x<=F(16,1))
y=(x-F(15,1))/(F(16,1)-F(15,1))*(F(16,2)-F(15,2))+F(15,2);
else if (F(16,1)<=x) &&(x<=F(17,1))
y=(x-F(16,1))/(F(17,1)-F(16,1))*(F(17,2)-F(16,2))+F(16,2);
else if (F(17,1)<=x) &&(x<=F(18,1))
y=(x-F(17,1))/(F(18,1)-F(17,1))*(F(18,2)-F(17,2))+F(17,2);
else if (F(18,1)<=x) &&(x<=F(19,1))
y=(x-F(18,1))/(F(19,1)-F(18,1))*(F(19,2)-F(18,2))+F(18,2);
else if (F(19,1)<=x) &&(x<=F(20,1))
y=(x-F(19,1))/(F(20,1)-F(19,1))*(F(20,2)-F(19,2))+F(19,2);
else if (F(20,1)<=x) &&(x<=F(21,1))
y=(x-F(20,1))/(F(21,1)-F(20,1))*(F(21,2)-F(20,2))+F(20,2);
else if (F(21,1)<=x) &&(x<=F(22,1))
y=(x-F(21,1))/(F(22,1)-F(21,1))*(F(22,2)-F(21,2))+F(21,2);
else if (F(22,1)<=x) &&(x<=F(23,1))
y=(x-F(22,1))/(F(23,1)-F(22,1))*(F(23,2)-F(22,2))+F(22,2);
else if (F(23,1)<=x) &&(x<=F(24,1))
y=(x-F(23,1))/(F(24,1)-F(23,1))*(F(24,2)-F(23,2))+F(23,2);
else if (F(24,1)<=x) &&(x<=F(25,1))
y=(x-F(24,1))/(F(25,1)-F(24,1))*(F(25,2)-F(24,2))+F(24,2);
else if (F(25,1)<=x) &&(x<=F(26,1))
y=(x-F(25,1))/(F(26,1)-F(25,1))*(F(26,2)-F(25,2))+F(25,2);
else if (F(26,1)<=x) &&(x<=F(27,1))
y=(x-F(26,1))/(F(27,1)-F(26,1))*(F(27,2)-F(26,2))+F(26,2);
else if (F(27,1)<=x) &&(x<=F(28,1))
y=(x-F(27,1))/(F(28,1)-F(27,1))*(F(28,2)-F(27,2))+F(27,2);
else if (F(28,1)<=x) &&(x<=F(29,1))
y=(x-F(28,1))/(F(29,1)-F(28,1))*(F(29,2)-F(28,2))+F(28,2);
else if (F(29,1)<=x) &&(x<=F(30,1))
y=(x-F(29,1))/(F(30,1)-F(29,1))*(F(30,2)-F(29,2))+F(29,2);
else if (F(30,1)<=x) &&(x<=F(31,1))
y=(x-F(30,1))/(F(31,1)-F(30,1))*(F(31,2)-F(30,2))+F(30,2);
else if (F(31,1)<=x) &&(x<=F(32,1))
y=(x-F(31,1))/(F(32,1)-F(31,1))*(F(32,2)-F(31,2))+F(31,2);
end
end
e
评论13