How do I change the orientation of a marker randomly?

10 Ansichten (letzte 30 Tage)
vishakha vijaykumar am 12 Apr. 2017
Beantwortet: Thorsten am 12 Apr. 2017
I have created 2 random points represented by the '+' marker. I want to change the orientations of these 2 markers randomly. Can anyone help me out? This is my code so far
x=rand(1,2)*100;
y=rand(1,2)*100;
scatter(x,y,'+');
I want random orientations of the 2 '+' markers.
4 Kommentare2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
KSSV am 12 Apr. 2017
So is that the marker orientation you want to change? '+' is a marker which shows the location of your point on the graph. It is not the orientation of point.
vishakha vijaykumar am 12 Apr. 2017
Yup the marker orientation. I apologize for the mistake . I will rephrase my question. Thank you.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Roger Stafford am 12 Apr. 2017
If you mean random orientation with respect to the cartesian coordinate origin, and if the orientation change is to be the same for each point, then do this:
t = 2*pi*rand-pi;
x2 = x*cos(t)-y*sin(t);
y2 = x*sin(t)+y*cos(t);
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Thorsten am 12 Apr. 2017
You have to draw two crossing lines of a random angle. You cannot change the orientation of Matlab's markers.
The following function may be useful; you have to adjust the size of marker using r depending on your axis, and use
axis equal
To get a random angle, set alpha to rand*2*pi.
function plotcrossmarker(alpha, r, x0, y0)
if nargin < 1, alpha = 0; end;
if nargin < 2, r = 1; end
if nargin < 3, x0 = 0; end
if nargin < 4, y0 = 0; end
x = r*cos(alpha);
y = r*sin(alpha);
xx = [-x x NaN -y y];
yy = [-y y NaN x -x];
line(xx + x0, yy + y0)
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by