Character vectors and strings in the first argument can only specify a variable or number.
3 次查看(过去 30 天)
显示 更早的评论
Character vectors and strings in the first argument can only specify a variable or number.
To evaluate character vectors and strings representing symbolic expressions, use str2sym
Tmr=3728;
Amr=932;
rho=0.002378;
Ohm=36;
Rmr=17.22;
smr=0.034;
Cla_d=0.11;
Cla_r=Cla_d/0.01745;
a=1131.55;
bmr=2;
CTreq=Tmr/(rho*Amr*(Ohm*Rmr)^2);
tetatwdeg=-12;
tetatwrad=tetatwdeg*0.01745;
for i=1:1:12
if i==1
teta0rad=(6*CTreq/(smr*Cla_r))-(0.75*tetatwrad+(0.75*sqrt(2)*sqrt(CTreq)));
else
teta0rad=(6*CTreq/(smr*Cla_r))-(0.75*tetatwrad+(1.5*sqrt(CTreq/2)));
end
myEqn = sym('teta0rad =(6*CT/(smr*Cla_r))-(0.75*tetatwrad+(1.5*sqrt(CT/2)))');
newEqn = subs(myEqn,{'teta0rad','smr','Cla_r','tetatwrad'}, [teta0rad,smr,Cla_r,tetatwrad]);
CTi=solve(newEqn);
teta0rad=teta0rad+(6*(CTreq-CTi)/(smr*Cla_r))+(0.75*sqrt(2)*(sqrt(CTreq)-sqrt(CTi)));
end
Why do I get that error?
0 个评论
采纳的回答
Walter Roberson
2021-12-11
change
myEqn = sym('teta0rad =(6*CT/(smr*Cla_r))-(0.75*tetatwrad+(1.5*sqrt(CT/2)))');
newEqn = subs(myEqn,{'teta0rad','smr','Cla_r','tetatwrad'}, [teta0rad,smr,Cla_r,tetatwrad]);
to
syms CT
newEqn = teta0rad == (6*CT/(smr*Cla_r))-(0.75*tetatwrad+(1.5*sqrt(CT/2))));
3 个评论
Walter Roberson
2021-12-12
Tmr=3728;
Amr=932;
rho=0.002378;
Ohm=36;
Rmr=17.22;
smr=0.034;
Cla_d=0.11;
Cla_r=Cla_d/0.01745;
a=1131.55;
bmr=2;
CTreq=Tmr/(rho*Amr*(Ohm*Rmr)^2);
tetatwdeg=-12;
tetatwrad=tetatwdeg*0.01745;
for i=1:1:12
if i==1
teta0rad=(6*CTreq/(smr*Cla_r))-(0.75*tetatwrad+(0.75*sqrt(2)*sqrt(CTreq)));
else
teta0rad=(6*CTreq/(smr*Cla_r))-(0.75*tetatwrad+(1.5*sqrt(CTreq/2)));
end
syms CT
newEqn = teta0rad == (6*CT/(smr*Cla_r))-(0.75*tetatwrad+(1.5*sqrt(CT/2)));
CTi=solve(newEqn);
teta0rad=teta0rad+(6*(CTreq-CTi)/(smr*Cla_r))+(0.75*sqrt(2)*(sqrt(CTreq)-sqrt(CTi)));
end
simplify(teta0rad)
double(teta0rad)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!