R = 8.3145;
m = 4;
h = 6.626 * 10.^(-34);
T6 = 300;
P6 = -100:0.1:100;
U6 = 3/2 * N * R * T6;
H6 = 5/2 * N * R * T6;
F6 = - N .* R .* T6 .* (1 + log(R .* T6 ./ P6 .* (2 * pi .* m .* R .* 3 ./ P6 ./ (h ^ 2)).^ 1.5));
G6 = - N .* R .* T6 .* (log(R .* T6 ./ P6 .* (2 * pi .* m .* R .* 3 ./ P6 ./ (h ^ 2)).^ 1.5));
plot(P6,U6,'r',P6,H6,'b',P6,F6,'y',P6,G6,'k')
grid on
title (' r: U(P),H(P),F(P),G(P) combine')

 采纳的回答

Star Strider
Star Strider 2018-9-19

0 个投票

The values for ‘U6’ and ‘H6’ are scalars. They are not functions of ‘P6’.
Also, you did not define ‘N’ in the code you posted.

8 个评论

thanks! how can i change it
What is your intention in plotting the scalar value U6 against the vector value P6 ?
i want to plot P6,U6,P6,H6,P6,F6,P6,G6 4 lines, but it just shows F6 and G6 on the plot
My pleasure.
I cannot determine that because I do not know what your original equations are or what you want to do with them. If you want to plot them as functions of ‘P6’, you have to write them as functions of ‘P6’.
If you intended:
U6 = 3/2 * N * R * P6;
H6 = 5/2 * N * R * P6;
You can plot them as you wrote in your plot call. I cannot determine if that is correct. I can claim only that ‘U6’ and ‘H6’ will then plot as lines.
Also, ‘F6’ and ‘G6’ are complex. The plot function will only display the real part of a complex vector. (I suspect the complex part is the result of the negative part of ‘P6’, so consider defining it only as a positive vector.)
it works! but the lines are overlap together.... do you know how to change the axis and make them dont overlap together?
I would do this:
figure
subplot(2,1,1)
plot(P6,U6,'r',P6,H6,'b')
grid on
title (' r: U(P),H(P)')
subplot(2,1,2)
plot(P6,F6,'y',P6,G6,'k')
grid
title('F(P),G(P) combine')
I might otherwise suggest using semilogy, however with ‘F6’ and ‘G6’ being negative, that will not work. It is easier to plot them separately in different subplot axes.
u are amazing! thank you!
As always, my pleasure! Thank you for your compliment!

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by