Info
This question is closed. Reopen it to edit or answer.
how to make looping for random data and discrete
1 view (last 30 days)
Show older comments
size = [0.35,0.45,0.8] L =rand(20,6) L = ['location',size] max = 33 min = 2
For column 1,3,5 will be detect for location and each row will be use this equation which is floor(L)*(max-min)+min.
for column 2,4,6 will be detect for size and each row will be measured as below:
if random value <0.3333 will be select size no 1 which is 0.35. if 0.3334< random value <0.6666 will be select size no 2 which is 0.45 if random value > 0.6667 will be select size no 3 which is 0.8
i already do this programming but my programming to long. so i dont know to to use looping programing or find programming to integrate with this data.
i hope you guys can help me.
0 Comments
Answers (1)
Roger Stafford
on 17 Dec 2014
(You should not use the name 'size' for one of your variables, since that is the name of one of matlab's functions, so I have taken the liberty of changing it to 'sz'.)
I am having to guess about the following because I am not sure I entirely understand your description. However, if it is incorrect, perhaps you can use its ideas to develop a correct algorithm. One of my uncertainties is where you want the results to be placed. I assumed here you wanted them placed back in 'L'.
sz = [0.35,0.45,0.8];
max = 33; min = 2;
L = rand(20,6);
L(:,[1,3,5]) = floor(L(:,[1,3,5]))*(max-min)+min;
t1 = L(:,[2,4,6]) > 1/3;
t2 = L(:,[2,4,6]) > 2/3;
L(:,[2,4,6]) = (~t1)*sz(1)+(t1&(~t2))*sz(2)+t2*sz(3);
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!