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 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