Plotting issue where the curve is missing

1 次查看(过去 30 天)
dear sirs, pls help me with my problem. I want to make a heat flow and time plot where the curve is missing
Phi_b = (1 - 0.9307) *491390.8868;
time = 0:0.1:17;
plot(Phi_b, time, 'LineWidth', 2);
title('Heat Flow Entering Block vs. Time');
xlabel('Time (s)');
ylabel('Heat Flow Entering Block (\Phi_b)');
grid on;

采纳的回答

Angelo Yeo
Angelo Yeo 2023-11-23
Specify a marker shape and color to make it explicit.
Phi_b = (1 - 0.9307) *491390.8868;
time = 0:0.1:17;
plot(Phi_b, time, 'o', 'markeredgecolor', lines(1), 'markerfacecolor','w', 'LineWidth', 2);
title('Heat Flow Entering Block vs. Time');
xlabel('Time (s)');
ylabel('Heat Flow Entering Block (\Phi_b)');
grid on;

更多回答(2 个)

Sam Chak
Sam Chak 2023-11-23
The reason is that Phi_b is a constant, and time is a vector. They don't have the same dimension.
Phi_b = (1 - 0.9307) *491390.8868
Phi_b = 3.4053e+04
time = 0:0.1:17
time = 1×171
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000

Walter Roberson
Walter Roberson 2023-11-23
编辑:Walter Roberson 2023-11-23
Phi_b = (1 - 0.9307) *491390.8868;
That is a scalar constant
time = 0:0.1:17;
vector
plot(Phi_b, time, 'LineWidth', 2);
The scalar constant is used as the independent (x) variable and the time is used as the dependent (y) variable. Note that the labels on your graph indicate that the independent variable is expected to be time
When you use a scalar x and a vector y, then matlab treats that as a request to plot multiple lines, the first defined by the scalar x against the first element of y; the second as the scalar x against the second element of y, and so on. So one line is being created for each entry in y (that is, time because you put time in the dependent slot). So each line is exactly one point.
In plot() the default is not to use any markers unless the user specifies markers in the call. But also plot only creates lines when there are at least two adjacent finite points. Since you are effectively plotting scalars each time, no lines are drawn and with the default being no markers, there are also no markers to indicate the individual points.
This explains why you do not see anything plotted.
If you have a constant y you want to plot consider using yref()

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by