MATLAB Answers

C Zeng

About vector comparasion question.

Asked by C Zeng
on 2 Apr 2013

Hi, I know I have asked the similar question, I want to write a if statement that compare vectors, like a, b is 3 dimensional vector, however if a<=b returns a 3-dim vector that do the comparison for each entry.

Is there a command just do a whole comparison at once? Thanks.



No products are associated with this question.

1 Answer

Answer by Mahdi
on 2 Apr 2013
 Accepted answer

Have you tried using the 'or' operator?

if size(a,2)==3 | size(b,2)==3
elseif size(a,1)<=size(b,1)

Sorry, you weren't very clear, but I hope some of the above will help.


Oh, yes, thanks, that function is very helpful!

Jan Simon
on 2 Apr 2013

@C Zeng: Flagging is used to tell the admins and editors, that a message violates the using conditions of the forum. Please press the "Accept" button instead of setting a flag. Thanks.

Sorry about that Jan! Thanks!

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!