Vary a parameter and plot the output
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I have the following script for which I am trying to determine how the outlet temperature (Tout) varies depending on the solar radiation (I) available. I have tried to set (I) as an array and run the code as a for loop but this doesn't seem to give the desired result. Additionally it doesn't plot (I) against (Tout) at the end. Can anyone provide me with some insight as to how to rectify this. I have attached the code.
Kind regards
0 Commenti
Risposta accettata
Star Strider
il 1 Apr 2020
Try this:
function main
x0 = [500 500 500 500 5 5];
opt = optimset('Display','off'); % 'display', 'iter'
I = [500 550 600 650 700 750]; % Solar radiation
for k = 1:numel(I)
res(k,:) = fsolve(@(x)f(x,I(k)),x0,opt);
% res'
end
figure
plot(I, res(:,3))
grid
xlabel('Solar Radiation')
ylabel('T_{out}')
end
That ran for me without error in R2020a.
12 Commenti
Star Strider
il 1 Apr 2020
The ‘Tout’ value is ‘res(:,3)’. Define it that way (perhaps as ‘Toutv’) and you should get the result you want:
Toutv = res(:,3);
n = m*cp*(Toutv-Tin)./I*A;
That should produce a vector rather than a matrix.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!