No plots generated in nested for loop

조회 수: 1 (최근 30일)
Neeraj Maurya
Neeraj Maurya 2023년 6월 22일
답변: Mayur 2023년 6월 22일
for k = 0:0.1:2
for j = 0:10:90
x = K^2./J
plot(k,x)
hold on
end
end

답변 (1개)

Mayur
Mayur 2023년 6월 22일
Hi Neeraj!
I understand that you're not able to see the plots. This is because the default marker symbol for plotting a line in MATLAB is no marker symbol. This means that by default, MATLAB will plot only a line connecting the specified data points, without any markers at the points themselves. Here, since you're plotting points individually, so no lines are displayed either.
You can modify your code to change the marker symbol to square like this:
for k = 0:0.1:2
for j = 0:10:90
x = k^2./j;
plot(k,x,'s')
hold on
end
end
For more information on plot, markers and its styling, please refer to the following documentation: https://www.mathworks.com/help/matlab/ref/plot.html

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by