A line does not appear when I plot

조회 수: 5 (최근 30일)
Elizabeth Frenzel
Elizabeth Frenzel 2023년 5월 15일
댓글: the cyclist 2023년 5월 15일
When I run this code it puts a graph with no line. how do I get the line to show?
  댓글 수: 2
the cyclist
the cyclist 2023년 5월 15일
If you post your code rather than an image of your code (or upload a *.m file), we can copy & paste it into MATLAB, which makes it much easier for us to help you.
the cyclist
the cyclist 2023년 5월 15일
FYI, it's very straightforward to write your code without any for loop at all, using vectorization.

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

채택된 답변

VBBV
VBBV 2023년 5월 15일
편집: VBBV 2023년 5월 15일
% inside the for loop
Temp(h) = q./(6*k_w)*(r_I.^2) + T_sI
% outside the for loop
Temp(Temp == 0 ) = [];
plot(1000:10000,Temp)
the above lines needs to be changed as shown, since you are plotting a point instead of a matrix
  댓글 수: 1
VBBV
VBBV 2023년 5월 15일
You can otherwise put the plot function command inisde the for loop and plot the results
hold on
for h = 1000:10000
% your code
plot(h,Temp,'ro','MarkerSize',12)
end

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

추가 답변 (1개)

the cyclist
the cyclist 2023년 5월 15일
The way you have coded this, both h and Temp are going to be scalars (single values) after the loop completes, so there is only one point to plot.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by