Generate random clsuter at a certain point in Matlab
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have the following two data set:
A= (1,1) 1.9643
(2,1) 2.2753
(3,1) 2.9781
(4,1) 2.9320
(5,1) 3.5772
(6,1) 4.0150
(7,1) 3.3814
(8,1) 3.9113
(9,1) 2.7822
(10,1) 2.5518
(11,1) 3.3698
(12,1) 3.1048
(13,1) 1.9182
(14,1) 2.2638
(15,1) 2.6555
(16,1) 3.1855
(17,1) 3.6579
(18,1) 3.9113
(19,1) 3.6002
(20,1) 3.0357
(21,1) 1.5841
(22,1) 2.0103
(23,1) 1.9527
(24,1) 2.2753
(25,1) 2.3099
(26,1) 2.8283
(27,1) 3.0473
(28,1) 2.4827
(29,1) 2.5057
(30,1) 1.8721
(31,1) 2.0103
(32,1) 1.2269
(33,1) 1.8951
(34,1) 1.5610
(35,1) 1.5495
(36,1) 1.6878
(37,1) 1.4919
(38,1) 0.9620
(39,1) 1.1693
(40,1) 0.8122
(41,1) 0.9735
(42,1) 1.2500
(43,1) 1.3191
(44,1) 2.2292
(45,1) 2.4482
(46,1) 2.7938
(47,1) 2.0910
(48,1) 2.5403
(49,1) 0.9044
(50,1) 0.7662
(1,2) 4.5957
(2,2) 3.8589
(3,2) 4.5651
(4,2) 3.5519
(5,2) 2.8560
(6,2) 3.1937
(7,2) 3.4291
(8,2) 4.1761
(9,2) 4.0431
(10,2) 4.6162
(11,2) 3.9101
(12,2) 3.0709
(13,2) 4.0534
(14,2) 4.3706
(15,2) 3.5008
(16,2) 4.2888
(17,2) 3.8692
(18,2) 3.4291
(19,2) 3.1221
(20,2) 3.3165
(21,2) 3.3575
(22,2) 3.2039
(23,2) 2.7843
(24,2) 2.7127
(25,2) 2.9584
(26,2) 2.6309
(27,2) 2.2931
(28,2) 2.0373
(29,2) 2.3853
(30,2) 2.0577
(31,2) 2.3546
(32,2) 2.3239
(33,2) 2.9174
(34,2) 3.0709
(35,2) 2.6923
(36,2) 2.4057
(37,2) 2.0271
(38,2) 2.6820
(39,2) 2.9276
(40,2) 2.9992
(41,2) 3.3881
(42,2) 3.1937
(43,2) 3.5109
(44,2) 2.2010
(45,2) 2.6411
(46,2) 1.9656
(47,2) 1.6177
(48,2) 2.8867
(49,2) 3.0198
(50,2) 2.5899
Here, A is two dimensional sparse matrix.
And B is (50,1) matrix, where the first 20 values are +1 and last 30 values are -1.
So the data point is look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158330/image.jpeg)
Now, I want to choose the (40,50) position of A and then want to generate 1000 random points within +/- 2 regions of the points.
So, the graph should be something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158331/image.jpeg)
Please let me know, how can I do it in matlab.
0 Commenti
Risposte (1)
Walter Roberson
il 20 Mar 2016
Modificato: Walter Roberson
il 20 Mar 2016
theta = rand(1000,1) * 2 * pi;
r = rand(1000,1) * 2;
[deltax, deltay] = pol2cart(theta, r);
randx = 40 + deltax;
randy = 50 + deltay;
0 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!