An error when "syms" is used

Hello
I would be appreciated if you could guide me why the following error has occured in phi(1), phi(2), and phi(3) as symbolic variables?!
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.
A piece of my code is :
a1 = 5.79e-08; a2 = 1.23e-07; a3 = 6.67e-08; a21=a2/a1; a32=a3/a2;
o1= w1*(Tb-Tts)+q_met1/k1;
o2= w2*(Tb-Tts)+q_met2/k2;
o3= w3*(Tb-Tts)+q_met3/k3;
syms s
syms t
syms x y z
Tb=310; Tts=310; Tini=309; % Assumption: Tb=Tts;
phi= zeros(3,1);
TT= Tini-Tts;
phi(1)= TT+(a1*o1)/s;
phi(2)= TT+(a2*o2)/s;
phi(3)= TT+(a3*o3)/s;

6 commentaires

Torsten
Torsten le 31 Mai 2021
You did not assign a numerical value to s. So the expression TT+a1*o1/s is symbolic. But you try to assign this expression to a numerical array, namely phi.
Mahsa Babaee
Mahsa Babaee le 31 Mai 2021
Dear @Torsten Thank you for your response.
You are right! But I want to define phi as a symbolic array. Is it possible? How can I do that?
Torsten
Torsten le 31 Mai 2021
Modifié(e) : Torsten le 31 Mai 2021
phi = sym('phi',[3 1])
Mahsa Babaee
Mahsa Babaee le 31 Mai 2021
Thanks a milion!
John D'Errico
John D'Errico le 31 Mai 2021
What is w21? w2? w3? Will you keep that a secret? :) If you don't tell us, how can we help you?
Then you try to convert something (unknown, again, you give us no clue) into a double. But does that variable contain symbolic unknowns? (It surely does, given the error.)
How can MATLAB convert something into a number when it is an unknown value?
And how can we help you if you don't give us any useful information?
Would you go to a doctor and tell him that you have an unknown problem, and then ask him to tell you the color car you drive?
Mahsa Babaee
Mahsa Babaee le 31 Mai 2021
I forgot to paste that! o1, o2, o3 and q_met1, q_met2, q_met3 and k1, k2, k3 are all known values!
I just want to define phi as a symbolic array and I did it as Torson explained.
Thank you for your time.

Réponses (0)

Cette question est clôturée.

Clôturé :

le 31 Mai 2021

Community Treasure Hunt

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

Start Hunting!

Translated by