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

답변 (2개)

Geoff Hayes
Geoff Hayes 2017년 11월 28일

0 개 추천

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 2017년 11월 28일

0 개 추천

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)

카테고리

도움말 센터File Exchange에서 Elementary Math에 대해 자세히 알아보기

질문:

2017년 11월 27일

답변:

2017년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by