symbolic system of equation

1 view (last 30 days)
bhop
bhop on 9 Jan 2020
Answered: M on 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

Answers (1)

M
M on 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.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!