5
points = [  
    -9.9043877608991468201413092380493, 426.34796945271797204125533010993, Maximum  
    -2.9714737944057521874892206269196, 422.13223302035451265143272598599, Minimum
    9.3758615553048990076305298649689, 441.87005169359418197397861057075, Maximum
]

I'd like to do loop through and create a new matrix with just the values where column three matches 'Maximum'.

When trying:

idx = ( points(:,3)=='Maximum' )

I get:

Maximum == Maximum
Minimum == Maximum
Maximum == Maximum

Any ideas? Thanks!

1 Answer 1

9

the matrix points as is presented is not a valid matlab matrix unless Maximum is a number. If that is the case then:

  idx=find( points(:,3)== Maximum  )

will give you the proper indices.

Edit

to obtain a new matrix with the values of "maximum" just

 new_matrix=points(idx,1:end-1)
Sign up to request clarification or add additional context in comments.

1 Comment

idx = 1 3 is what I get in return. What exactly are those two values? I've tried making sense of it but I can't. Also, how can I turn the values matching "Maximum" in the 3rd column into a new matrix?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.