Plot is making marker at origin

5 Ansichten (letzte 30 Tage)
Jared
Jared am 7 Dez. 2014
Kommentiert: Geoff Hayes am 7 Dez. 2014
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?

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 7 Dez. 2014
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 Kommentare
Jared
Jared am 7 Dez. 2014
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 am 7 Dez. 2014
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'));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by