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

回答(1 个)

Muhammad Usman Saleem
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
  1 个评论
Amine Ben Ayara
Amine Ben Ayara 2016-2-25
Muhammed, Thank you for your answer. I will make a very small numerical example and attach it to my edited question shortly.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by