Character vectors and strings in the first argument can only specify a variable or number.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alexi
le 11 Déc 2021
Commenté : Walter Roberson
le 12 Déc 2021
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 commentaires
Réponse acceptée
Walter Roberson
le 11 Déc 2021
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 commentaires
Walter Roberson
le 12 Déc 2021
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)
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!