Plot for different values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Luccas S.
am 15 Aug. 2021
Bearbeitet: Luccas S.
am 15 Aug. 2021
Hi, I'm trying to vary the value of Q but the values aren't changing.
HfTOTAL = 26.8708
Hg = 30
Q = 0:50:450;
K = HfTOTAL./Q.^1.852
Hm = Hg + K.*Q.^1.852 % m
KQ = K.*Q.^1.852
plot(Q,Hm,'k','LineWidth',2)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 15 Aug. 2021
Just for fun, let is assign Q.^1.852 to a variable, say Q18
HfTOTAL = 26.8708
Hg = 30
Q = 0:50:450;
Q18 = Q.^1.852;
K = HfTOTAL./Q18;
So K is something divided by Q18
Hm = Hg + K.*Q18 % m
And there you take K times Q18. But Q is something divided by Q18, so except for loss of precision due to round-off error, or inf or nan effects, then K*Q18 is going to be the same as the something that was then divided by Q18. So
Hm = Hg + repmat(HfTotal, 1, length(Q));
but that's just a repeated constant
KQ = K.*Q18
Again that is just the same as repmat(HfTotal, 1, length(Q)); so it is just a repeated constant.
plot(Q,Hm,'k','LineWidth',2)
You plot the different Q values with the repeated constant on the Y axes.
5 Kommentare
Walter Roberson
am 15 Aug. 2021
Using a for loop will not help.
HfTotal = 6
for Q = 1 : 3
K(Q) = HfTotal./Q
end
for Q = 1 : 3
Hm(Q) = K(Q) .* Q
end
The problem is that you are multipling by the exact same thing you are dividing by.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!