Plotting issue where the curve is missing
조회 수: 10 (최근 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()
참고 항목
카테고리
Help Center 및 File Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

