matlab循环求解b(0)=1;a(i)=b(i-1)+0.075;b(i)=∑a(i);y(i)=[∑(0.002-a(i))]*sin(b(i))求累加循环到在y(i)=4时,a,b,y和i的值
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 04:48:51
matlab循环求解b(0)=1;a(i)=b(i-1)+0.075;b(i)=∑a(i);y(i)=[∑(0.002-a(i))]*sin(b(i))求累加循环到在y(i)=4时,a,b,y和i的值
matlab循环求解
b(0)=1;
a(i)=b(i-1)+0.075;
b(i)=∑a(i);
y(i)=[∑(0.002-a(i))]*sin(b(i))
求累加循环到在y(i)=4时,a,b,y和i的值
matlab循环求解b(0)=1;a(i)=b(i-1)+0.075;b(i)=∑a(i);y(i)=[∑(0.002-a(i))]*sin(b(i))求累加循环到在y(i)=4时,a,b,y和i的值
clear all;
b0 = 1;
maxI = 100; %假设i最大取值为100
[a, b, y] = deal(zeros(1, maxI));
a(1) = b0 + 0.075;
b(1) = a(1);
y(1) = (0.002 - a(1))*sin(b(1));
for ii = 2:maxI
a(ii) = b(ii-1) + 0.075;
b(ii) = sum(a(1:ii));
y(ii) = sum(0.002 - a(1:ii))*sin(b(ii));
if y(ii) >= 4
break;
end
end
disp(['a:', num2str(a(ii)), ' b:', num2str(b(ii)), ' y:', num2str(y(ii)), ' i:', num2str(ii)]);
结果:
a:2.3 b:4.525 y:4.4399 i:3