Plotting issue where the curve is missing

조회 수: 10 (최근 30일)
Lutfi
Lutfi 2023년 11월 23일
편집: Walter Roberson 2023년 11월 23일
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;
  댓글 수: 1
Lutfi
Lutfi 2023년 11월 23일
I appreciate your input.thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (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()
  댓글 수: 1
Lutfi
Lutfi 2023년 11월 23일
many thanks,your explanation is very easy to understand

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by