# How to solve algebraic equations for different values of variables ?

36 Ansichten (letzte 30 Tage)
Aiden James am 24 Mai 2024 um 5:45
Kommentiert: Aiden James am 24 Mai 2024 um 11:23
I am new to MATLAB, I want to solve the equation “eqn” to get the values of “Te” for different values of I. How solve thIS equation. I have made the code. But I am not getting the numerical valueS of “Te”.
clear all
close all
clc
% For ETC collector
syms Te
filename = '1.xlsx';
% Convert table to array
T= table2array(T);
% Inpit data
Ac=repelem(2,480)
I=T'
eta_0=0.7
a1=repelem(5,480)
a2=repelem(0.0057,480)
Ti =repelem(30,480)
T_air=repelem(30,480)
m =repelem(0.04,480)
c =repelem(4,480)
% Efficiency of collector
eta=(eta_0-a1.*(((Ti+Te)./2)-T_air)./I-a2.*(((Ti+Te)./2)-T_air).^2./I);
% Solve the equation
eqn = Ac.*I.*eta-m.*c.*(Te-Ti);
S = solve(eqn,Te);
% NOTE: there are 2 roots for above equation so consider positive value only
S=round(S)
S = S( S>=0 )
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Aiden James am 24 Mai 2024 um 8:17
Thanks for quick reply. Please find the data file in the attachment.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

VBBV am 24 Mai 2024 um 6:26
```eqn = Ac.*I.*eta-m.*c.*(Te-Ti)==0;
```
##### 3 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
VBBV am 24 Mai 2024 um 10:59
Bearbeitet: VBBV am 24 Mai 2024 um 11:07
@Aiden James, you have vector of equations to solve and only one unknown to determine the value for those vector of equations. You can solve them by using a for loop as shown below
clear all
close all
clc
% For ETC collector
syms Te
filename = 'a1.xlsx';
% Convert table to array
T= table2array(T);
% Inpit data
Ac=repelem(2,480);
I=T';
eta_0=0.7;
a1=repelem(5,480);
a2=repelem(0.0057,480);
Ti =repelem(30,480);
T_air=repelem(30,480);
m =repelem(0.04,480);
c =repelem(4,480);
% Efficiency of collector
eta=(eta_0-a1.*(((Ti+Te)./2)-T_air)./I-a2.*(((Ti+Te)./2)-T_air).^2./I);
% Solve the equation
eqn = Ac.*I.*eta-m.*c.*(Te-Ti)==0;
for k = 1:numel(eta)
S{k} = solve(eqn(k),Te);
end
S = S{:}
S =
% NOTE: there are 2 roots for above equation so consider positive value only
S = vpa(S,3)
S =
S = double(S(S>=0))
S = 125.3670
Aiden James am 24 Mai 2024 um 11:23
Thanks

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Torsten am 24 Mai 2024 um 9:51
% Solve the equation
eqn = Ac.*I.*eta-m.*c.*(Te-Ti)==0
for i=1:numel(eqn)
s = solve(eqn(i),Te);
S(i) = vpa(s(s>=0));
end
S
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Aiden James am 24 Mai 2024 um 11:23
Thanks

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Linear Algebra finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by