A line does not appear when I plot

6 Ansichten (letzte 30 Tage)
Elizabeth Frenzel
Elizabeth Frenzel am 15 Mai 2023
Kommentiert: the cyclist am 15 Mai 2023
When I run this code it puts a graph with no line. how do I get the line to show?
  2 Kommentare
the cyclist
the cyclist am 15 Mai 2023
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 am 15 Mai 2023
FYI, it's very straightforward to write your code without any for loop at all, using vectorization.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

VBBV
VBBV am 15 Mai 2023
Bearbeitet: VBBV am 15 Mai 2023
% 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 Kommentar
VBBV
VBBV am 15 Mai 2023
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

the cyclist
the cyclist am 15 Mai 2023
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.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by