Vary a parameter and plot the output
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2020-4-1
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 个评论
Star Strider
2020-4-1
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!