How to verify a while loop and run it correctly?

1 view (last 30 days)
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

Answers (1)

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

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!