Scatter plot random values
이전 댓글 표시
I have got a array of random variables: A=rand(1,25);
I have to scatter plot A within X and Y axis. The limits of both X axis and Y axis are 0 to 1. There is no relation between the random variables A and X,Y axis.
How can I do this? If at all this is possible, how can I obtain the x and y coordiantes of the 25 points that have been plotted?
Please help.
Thanks in advance.
댓글 수: 9
Optics Wizard
2020년 4월 9일
Currently, A=rand(1,25) is a 1D array. Are you trying to plot 25 random points in 2D X-Y?
If so:
A = rand(2,25);
X = A(1,:);
Y = A(2,:);
scatter(X,Y)
Alternatively:
X = rand(1,25);
Y = rand(1,25);
scatter(X,Y)
Swagato Das
2020년 4월 10일
Swagato Das
2020년 4월 10일
Walter Roberson
2020년 4월 10일
x = rand(size(A));
y = rand(size(A));
%A(J,K) got scattered to X(J,K), Y(J,K)
Rik
2020년 4월 10일
The second code example should work for you. What do you want to do with the values of A? Nothing? Or should they be used as text labels?
Swagato Das
2020년 4월 10일
joel malcolm
2022년 9월 6일
이동: Rik
2022년 9월 6일
Hi Im trying to place random points inside a rectangular area that has a curve through the graph. I have doen this but plotting this on a graph is not working
Walter Roberson
2022년 9월 6일
You could get John d'Errico's interparc from the file exchange. Describe the curve by a series of line segments. Now generate the appropriate number of random points in the range 0 to 1 times the length of the curve, and interparc to find out the x y coordinates where those points fall. The points will be in random locations and they will be somewhere along the curve as required.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!