symbolic system of equation

2 次查看(过去 30 天)
bhop
bhop 2020-1-9
回答: M 2020-1-9
Hi,
It is first time studying on symbolic expressions. I face ''error using zeros'' error when I run following code. Is there anyone can help me about this ?
PS. I added equations as image.
syms gamma w u aoa pi dt b rho
gamma=sym(zeros(i,1));
w=sym(zeros(i,1));
l=sym(zeros(i,1));
for i=1:1:5
if i==1
% rhs1(i)=0
% rhs2(i)=-u*aoa
eqn1=gamma(i)+w(i)==0;
eqn2=gamma(i)+w(i)/(2*pi*((b/2)+(u*dt)/2))==-u*aoa;
else
rhs1=0;
rhs2=-u*aoa;
for j=1:1:i-1
rhs1=-w(j)+rhs1;
rhs2=-w(j)/(2*pi*((b/2)+(((2*i-2*j)+1)*u*dt)/2));
eqn1=gamma(i)+w(i)==rhs1;
eqn2=gamma(i)+w(i)/(2*pi*((b/2)+(u*dt)/2))==rhs2;
eqns=[eqn1,eqn2];
sol=vpasolve(eqns,[gamma(i),w(i)]);
sol.gamma;
sol.w;
end
end
end
if i==1
l(i)=2*b*rho*gamma(i)+rho*u*gamma(i);
else
l(i)=2*b*rho*(gamma(i)-gamma(i-1))+rho*u*gamma(i);
end

回答(1 个)

M
M 2020-1-9
First problems on lines 2 to 4:
gamma=sym(zeros(i,1));
w=sym(zeros(i,1));
l=sym(zeros(i,1));
i is not yet defined.

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by