Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

My program isn't plotting anything

조회 수: 1 (최근 30일)
Samuel Garcia
Samuel Garcia 2020년 2월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
I made a program meant to plot two arrays in an elipse like graph, but nothing is showing up when i call the plot function. I made sure the function is outside of my loops like so, yet nothing is showing up, what am I doing wrong?
for i=1:360
x1(i)=a;
y1(i)=b;
end
plot(x1,y1)

답변 (2개)

Cameron B
Cameron B 2020년 2월 23일
I’m assuming your variables a and b are actual values. If not, it will obviously give an error that a and b are undefined. I think you have the visibility of your figure turned off. Also I would rename your variable from i to ii in order to avoid confusion with the built in identity of i=sqrt(-1). Try this:
close all
fig=figure;
fig.Visible='on';
for ii=1:360
x1(ii)=a; %a should be some number
y1(ii)=b; %b should be some number
end
plot(x1,y1)

Walter Roberson
Walter Roberson 2020년 2월 23일
All of your x are the same, and all of your y are the same. You are drawing a line from a point to itself over and over again. That would create at most one dot on the screen. You could add '-*' as a plot option to make the one point more obvious.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by