Plotting issue where the curve is missing
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Angelo Yeo
on 23 Nov 2023
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;
More Answers (2)
Walter Roberson
on 23 Nov 2023
Edited: Walter Roberson
on 23 Nov 2023
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()
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!