symbolic system of equation

1 回表示 (過去 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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by