symbolic system of equation

2 Ansichten (letzte 30 Tage)
bhop
bhop am 9 Jan. 2020
Beantwortet: M am 9 Jan. 2020
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

Antworten (1)

M
M am 9 Jan. 2020
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.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by