Plot is making marker at origin

조회 수: 5 (최근 30일)
Jared
Jared 2014년 12월 7일
댓글: Geoff Hayes 2014년 12월 7일
In my gui code for plotting resultant vectors from gravity, when I plot the circles to represent point masses, I'm getting a marker at the origin. I don't know why it shows a marker, but it only seems to do it whenever one point is far enough away from the origin to move the boundary of the graph.
%get user data from gui
plot(x1,y1,'.','markersize',60)
hold on
plot(x2,y2,'.r','markersize',60)
hold off
The problem occurs in the plot, where a 3rd marker is appearing with the characteristics of the last marker created at the origin. How can I remove this 3rd marker from the plot as it is not needed?

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 12월 7일
Jared - are x1, y1, x2, y2 scalars or vectors? If they are vectors, then you could very well be replacing the original point, (x1,y1), with the marker depending upon how you are creating x2 and y2. For example,
figure;
x1 = 10;
y1 = 10;
x2 = [x1 50];
y2 = [y1 50];
plot(x1,y1,'.','markersize',60)
hold on
The above call to plot creates a blue dot at the centre ("origin") of the figure. And once we call
plot(x2,y2,'.r','markersize',60)
hold off
because x2 and y2 include the origin of (x1,x2), the original blue dot is replaced with the red marker. Is this what is happening?
  댓글 수: 3
Jared
Jared 2014년 12월 7일
So I unsilenced the x1 y1 x2 and y2 variables, theyre all vectors with values that was input and a zero in the next row. I believe this is due to them being called as doubles. How do I convert the string to just their numeric value?
Geoff Hayes
Geoff Hayes 2014년 12월 7일
Jared - what happens if you just call
get(hx1,'String')
without the str2double? What do you observe?
As an aside, you shouldn't have to use findobj to get the handles to your widgets. Just use
m1 = str2double(get(handles.Mone,'String'));
instead of
hm1 = findobj('tag','Mone');
m1 = str2double(get(hm1,'String'));

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by