How to verify a while loop and run it correctly?
2 次查看(过去 30 天)
显示 更早的评论
Hello, I have written a code using a while loop. which basically uses 3 input matrices, two of which are identical in dimensions, suppose (10*3): MI1, and MI2. the third one is (10*100): MI3. The objective is to get a final matrix: M that is (n*3), the nbr of rows depends on the conditions that while loop has to check: My simulation is based on these steps: 1st row of the output matrix M is = to the the 1st row of MI1. then it compares MI1(2,3) to MI2(1,3), if MI1(2,3)>max(MI2(:,3:end) then M(2,:)=MI1(2,:), else M(2,:)=MI2(row(where the max is),:); then the max(MI2) selected already is replaced by a value from MI3, indexed at MI2((where the max is, 2))+1; and this will continue until the loop runs throw all the rows of MI1. I can provide my code and a very small data set if necessary. I hope my explanation is clear.
Thanks
0 个评论
回答(1 个)
Muhammad Usman Saleem
2016-2-25
edit your question again and post code with error you are getting?
Only after my understanding i recommend you to use For loop rather than While loop which may run for infinity iritations
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!