how to make looping for random data and discrete
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
답변 (1개)
Roger Stafford
2014년 12월 17일
(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
Muhammad
2014년 12월 18일
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!