0

I want to get A'=[1 0 3 0]' from A=[1 10 3 100]' from the below MATLAB code

new_A=A(A<10) 

But it does not work.

I need to do this without for or if.

2
  • What language are you using? That would be a helpful detail to add. Commented Oct 20, 2015 at 5:54
  • just add it, do you know how? Commented Oct 20, 2015 at 5:57

1 Answer 1

5

(A < 10) is a binary matrix of the same size as A. Thus this should do the job:

A .* (A < 10) 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot. I guess you are genius!
Technically A<10 returns a logical matrix, which is represented as binaries. Good answer none the less

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.