matlab出错:The expression to the left of the equals sign is not a valid target for an assignment? P(i+1)=P(i)*(V(i)-S*v(i)*dt(i))/(V(i)-sigma(i)*dt(i)); |Error: The expression to the left of the equals sign is not a valid t
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 09:44:44
matlab出错:The expression to the left of the equals sign is not a valid target for an assignment? P(i+1)=P(i)*(V(i)-S*v(i)*dt(i))/(V(i)-sigma(i)*dt(i)); |Error: The expression to the left of the equals sign is not a valid t
matlab出错:The expression to the left of the equals sign is not a valid target for an assignment
? P(i+1)=P(i)*(V(i)-S*v(i)*dt(i))/(V(i)-sigma(i)*dt(i));
|
Error: The expression to the left of the equals sign is not a valid target for an assignment.
程序如下
P=1:100;
P(1)=10100;
m=70;
g=9.8;
h=0.762;
N=100;
dz=h/N;
v0=4.27;
S=0.581;
dt=1:100;
dt(1)=h/(v0*N);
V=1:100;
for i=1:100
V(i)=S*(101-i);
end
z=1:100;
for ii=1:100
z(ii)=h/N*(ii-1);
end
e=2.71828;
sigma=1:100;
for iii=1:100
sigma(iii)=2*S*e.^(4*z(iii)/h);
end
v=1:100;
v(1)=v0;
for j=1:99
{
P(i+1)=P(i)*(V(i)-sigma(i)*dt(i))/(V(i)-S*v(i)*dt(i));
v(i+1)=sqrt((m*g*dz-P(i+1)*S*dz+0.5*m*v(i)*v(i))/(0.5*m));
dt(i+1)=h/(v(i+1)*N);
}
end
matlab出错:The expression to the left of the equals sign is not a valid target for an assignment? P(i+1)=P(i)*(V(i)-S*v(i)*dt(i))/(V(i)-sigma(i)*dt(i)); |Error: The expression to the left of the equals sign is not a valid t
你的循环变量是j啊...
把最后一个for循环里的i全改成j就好.
再多说句,matlab里面最好不要用i和j做循环变量,很容易和复数运算混淆.最好用m,n,k,l之类的.