Could any one please help me write the code to solve this system of equations?
Fcl=1/(1+0.155*Iclo*h);
hr=4*5.67*0.00000001*0.72*facl*((0.5*(Tcl+To)+273)^3);
To=(hr*Tr+hc*Ta)/h;
Tcl=To+Fcl(Tsk(i)-To);
h=hc+hr;
Unknown: Fcl hr To Tcl h.
Others are known.
I'm a beginner, I follow the format but error always shoot out. Want quick respond thank you.

1 Kommentar

jin wang
jin wang am 12 Okt. 2015
Bearbeitet: jin wang am 12 Okt. 2015
What I wrote is like these.
syms Fcl hr To Tcl h
eqn1 = Fcl==1/(1+0.155*Iclo*h);
eqn2 = hr==4*5.67*0.00000001*0.72*facl*((0.5*(Tcl+To)+273)^3);
eqn3 = To==(hr*Tr+hc*Ta)/h;
eqn4 = Tcl==To+Fcl(Tsk(i)-To);
eqn5 = h==hc+hr;
[Fcl,hr,To,Tcl,h] = solve([eqn1,eqn2,eqn3,eqn4,eqn4,eqn5],[Fcl,hr,To,Tcl,hl])

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Okt. 2015

0 Stimmen

Is Fcl a function or a value? If it is a value then you need explicit multiplication with respect to (Tsk(i)-To)
Note that by default "i" refers to sqrt(-1) so your Tsk(i) may be trying to index Tsk(sqrt(-1)) unless you have assigned something else to i
The statements you show by themselves are not enough: you need to define numeric values for the other variables or you need to declare them as syms . If you take the syms route then I recommend changing Tsk(i) to just plain Tsk since the indexing does not matter to the solution of the equations.
The solution involves the roots of a polynomial of degree 7 whose leading term is equivalent to
158193*Iclo*facl*(31*Iclo*Ta*hc-31*Iclo*Tr*hc-200*Tr+200*Tsk(i))^3 * x^7
Because it is a 7 degree polynomial, the answer you get is going to be in terms of RootOf() and there is unlikely to be a closed form solution in the standard operations. You are going to need to solve for numeric roots by using vpasolve() or using double()

15 Kommentare

jin wang
jin wang am 12 Okt. 2015
Thank you for your help.
All the unknowns, including Fcl, are value and not function.And all the other symbols are given a specific value before I solve this system of equation. So it should be just like 5 unknowns and five equations problem. And the index i is used for a for loop, since this system of equations will be solved many times. Forgive me since I am a Matlab starter. I tried to use vpasolve() but still not working.
Walter Roberson
Walter Roberson am 12 Okt. 2015
What is the result you get from vpasolve() ?
jin wang
jin wang am 12 Okt. 2015
The error is shown:
Error using sym/subsindex (line 732) Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and the body of the function is a SYM expression. When indexing, the input must be numeric, logical, or ':'.
Error in sym/subsref (line 771) R_tilde = builtin('subsref',L_tilde,Idx);
Error in test (line 138) eqn4 = Tcl==To+Fcl(Tsk(k)-To);
Torsten
Torsten am 12 Okt. 2015
eqn4 = Tcl==To+Fcl*(Tsk(k)-To);
Best wishes
Torsten.
jin wang
jin wang am 12 Okt. 2015
Thank you. I correct it. But still got error:
Error using symengine (line 59) The dimensions do not match.
Error in sym/privBinaryOp (line 903) Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in * (line 244) X = privBinaryOp(A, B, 'symobj::mtimes');
Torsten
Torsten am 12 Okt. 2015
Substitute "hl" by "h" in your call to "solve":
[Fcl,hr,To,Tcl,h] = solve([eqn1,eqn2,eqn3,eqn4,eqn4,eqn5],[Fcl,hr,To,Tcl,h])
instead of
[Fcl,hr,To,Tcl,h] = solve([eqn1,eqn2,eqn3,eqn4,eqn4,eqn5],[Fcl,hr,To,Tcl,hl])
If this still does not work, post again the complete code you are using.
Best wishes
Torsten.
Walter Roberson
Walter Roberson am 12 Okt. 2015
I did point out that you needed that explicit multiplication...
jin wang
jin wang am 12 Okt. 2015
Bearbeitet: Walter Roberson am 12 Okt. 2015
function RC = rcloss(k,hc,Iclo,facl,Ta,Tsk,Tr)
%solving multiple equations:
syms Fcl hr To Tcl h
eqn1 = Fcl-(1/(1+(0.155*Iclo*h)));
eqn2 = hr-(4*5.67*0.00000001*0.72*facl*((0.5*(Tcl+To)+273)^3));
eqn3 = To-((hr*Tr+hc*Ta)/h);
eqn4 = Tcl-(To+Fcl*(Tsk(k)-To));
eqn5 = h-hc-hr;
[Fcl,hr,To,Tcl,h] = vpasolve(eqn1,eqn2,eqn3,eqn4,eqn5);
RC=Fcl*h*(Tsk(k)-To);
end
And the error says:
Error using symengine (line 59)
The dimensions do not match.
Error in sym/privBinaryOp (line 903)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in * (line 244)
X = privBinaryOp(A, B, 'symobj::mtimes');
Error in rcloss (line 10)
RC=Fcl*h*(Tsk(k)-To);
Error in test (line 133)
RC=rcloss(k,hc,Iclo,facl,Ta,Tsk,Tr);
Are any of your parameters vectors or matrices, other than Tsk ?
Note that you are expecting multiple results (7 of them), so you are asking to multiply vectors by vectors. You should consider
RC = Fcl .* h .* (Tsk(k)-To);
jin wang
jin wang am 12 Okt. 2015
I define Fcl,h and To as syms as u can see. But when I check the workspace, I found that Fcl,h,and To are all 7x1 sym which includes a column of 1x1 syms.I don't know why this happens.
Torsten
Torsten am 12 Okt. 2015
Because you get 7 solutions for your system ...
Best wishes
Torsten.
jin wang
jin wang am 12 Okt. 2015
Okay. Thank you so much. I understand now.But if I only need one solution so that the dimension would match later-on equation solvings. What should I do?
Walter Roberson
Walter Roberson am 12 Okt. 2015
How would you know which of the 7 solutions is the right one? For example do you know that for one of the variables, the imaginary part of the variable is negative?
jin wang
jin wang am 12 Okt. 2015
Exactly, so I should use this 7 sloution matrix to substitute into the following calculation? I keep receiving dimension not match error.
jin wang
jin wang am 12 Okt. 2015
Let's say I want to use RC and E which is 7x1 sym in the following code like this. How can I achieve this outcome?
Tsk(1+k,1)=Tsk(k,1)+deltat*(F(5)*(H(5)+(K(4)*(Tvsk(k,1)-Tsk(k,1)))-(RC+E)));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

John BG
John BG am 12 Okt. 2015

0 Stimmen

Could you please define ranges for each unknown? Be conservative, please define the following: Fcl_min= Fcl_max= hr_min= hr_max= To_min= To_max= Tcl_min= Tcl_max= h_min= h_max=

1 Kommentar

jin wang
jin wang am 12 Okt. 2015
you mean give them specific value or just write what you have writen in the code. I don't know why to do this.

Melden Sie sich an, um zu kommentieren.

John BG
John BG am 31 Jan. 2016

0 Stimmen

Mr Robertson considers as variables parameters that Mr Wang does not want to include as variables. I asked Mr Wang to define ranges because if the symbolic analysis does not help, then having a look at the equations may be useful, let me explain:
Since Mr Wang does not say anything else about the parameters, let me list them
eq1: Iclo assumed constant
eq2: facl and Tc assumed constant
eq3: Tr, Ta and hc assumed constant
eq4: Tsk(i) assumed constant
eq5: as in eq3, hc assumed constant
So, we have 5 variables to solve: Fcl hr To Tcl h
that I rename to: x y z w v
The simplified version of the 5 initial equations is:
eq1: x=1/(1+v)
eq2: y=((1+z)*.5+2)^3
eq3: z=(y+1)/v
eq4: w=z+x*(1-z)
eq5: v=1+y
I have define 5 ranges, that some of them may or may not help solve the system, but at least it's a start point:
x_min=-10;x_max=10;x_step=.1;x_range=[x_min:x_step:x_max]
y_min=-10;y_max=10; y_step=.1; y_range=[y_min:y_step:y_max]
z_min=-10;z_max=10; z_step=.1; z_range=[z_min:z_step:z_max]
w_min=-10;w_max=10; w_step=.1; w_range=[w_min:w_step:w_max]
v_min=-10;v_max=10; v_step=.1; v_range=[v_min:v_step:v_max]
now
v=v_range
x=1./(1+v)
figure(1);plot(v,x);grid on;hold all
z=z_range
y=((1+z)*.5+2).^3
figure(2);plot(z,y);grid on;w=z+x*(1-z)
simplifying some equations is possible:
eq3 and eq5 yield z=(y+1)/(1+y) nearly constant
eq4 with z nearly constant means w shape is w=1+x
I said 'nearly constant' because the simplified equations do not include the the parameters
Including parameters: Iclo facl Tc Tr Ta Tsk(i) hc
renamed: k1 k2 k3 k4 k5 k6 k7
eq1: x=1/(1+k1*v)
eq2: y=k2*((k3+z)*.5+2)^3
eq3: z=(k4*y+k5*k7)/v
eq4: w=z+x*(k6-z)
eq5: v=k7+y
give values to parameters, and find out if the 5 equations have a solution, or if perhaps the only way to solve this equations system is for values of parameters and variables within certain range windows.
Let me know if you progress with anything above explained
John

Community Treasure Hunt

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

Start Hunting!

Translated by