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)

 Réponse acceptée

Walter Roberson
Walter Roberson le 15 Août 2021

1 vote

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 commentaires

Luccas S.
Luccas S. le 15 Août 2021
Modifié(e) : Luccas S. le 15 Août 2021
Didn't know the repmat function, cool.
I don't know if you tried it, but it still gives me the same graph as before.
Right, I was not suggesting to you that you use repmat, I was saying that your code was the same as if you used repmat.
Suppose you have
Q = 1:3
Q = 1×3
1 2 3
HfTOTAL = 6
HfTOTAL = 6
K = HfTOTAL./Q
K = 1×3
6 3 2
So a constant divided by the different Q values
Hm = K.*Q
Hm = 1×3
6 6 6
And then you multiply by the different Q values.. the result is going to be the same as the constant repeated to the same length as Q. (A/B)*B gives back A (copied according to the size of B)
You are always going to get a straight line as long as you have
K = HfTOTAL./Q.^1.852
Hm = Hg + K.*Q.^1.852
where you are multiplying by the exact same thing you divided by.
Luccas S.
Luccas S. le 15 Août 2021
Hmmm, got it.
I think it would be better to try using a for or while. From what you told me it won't work out this way right?
Using a for loop will not help.
HfTotal = 6
HfTotal = 6
for Q = 1 : 3
K(Q) = HfTotal./Q
end
K = 6
K = 1×2
6 3
K = 1×3
6 3 2
for Q = 1 : 3
Hm(Q) = K(Q) .* Q
end
Hm = 6
Hm = 1×2
6 6
Hm = 1×3
6 6 6
The problem is that you are multipling by the exact same thing you are dividing by.
Luccas S.
Luccas S. le 15 Août 2021
Modifié(e) : Luccas S. le 15 Août 2021
I found my mistake, silly thing.
I should be plotting as a function of the Q m³/h in a part I hadn't posted, and I was plotting as a function of the Q m³/s. Never that it was going to work.
Sometimes it's better to go for a walk and come back hahaha

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by