How to create a plot with this values

I need to modify this code, I do get all the efficiency Values but I do not how I could plot it. the plot will be Efficiency vs j (increments from 0.7 to 1 )
for j=0.7:0.01:1
h2=h1+((hT2s-h1)/(j));
hT4=hT3-(j)*(hT3-hT4s);
Efficiency=1-(hT4-h1)/(hT3-h2);
end

Réponses (2)

Geoff Hayes
Geoff Hayes le 28 Nov 2017
David - just create an array of the efficiency values which you will update on each iteration of the loop. For example,
increments = 0.7:0.1:1;
efficiencies = size(increments);
for k=1:length(increments)
j = increments(k);
h2=h1+((hT2s-h1)/(j));
hT4=hT3-(j)*(hT3-hT4s);
efficiencies(k) = 1-(hT4-h1)/(hT3-h2);
end
plot(increments, efficiencies);
Akira Agata
Akira Agata le 28 Nov 2017
I believe you can avoid for-loop by vectorizing variables. Assuming h1, hT2s, hT3 and hT4s are constant value, you can calculate Efficiency vs x = 0.7:0.01:1 and plot them by:
h1 = 1;
hT2s = 2;
hT3 = 3;
hT4s = 4;
x = 0.7:0.01:1;
h2 = h1+((hT2s-h1)./x);
hT4 = hT3-x*(hT3-hT4s);
Efficiency = 1-(hT4-h1)./(hT3-h2);
plot(x,Efficiency)

Catégories

En savoir plus sur Elementary Math dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by