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;
0 个评论
采纳的回答
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 个)
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()
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!