Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Array dimensions must match for binary array op.

681 views
Skip to first unread message

Torsten Imig

unread,
Jun 28, 2002, 11:58:58 AM6/28/02
to
i get this error:
Error using ==> ==
Array dimensions must match for binary array op.

from this code:

if onlineoffline == 'online'
msgbox('onlinemode')
break, end
end

if onlineoffline == 'online' everything works fine,
but when it is not true this error appears.

what i want to reach is that the callback stops
if onlineoffline == 'online' and if not, just go on,

whtas wrong ?
thanks for help,

Lars Gregersen

unread,
Jun 28, 2002, 1:28:30 PM6/28/02
to
On Fri, 28 Jun 2002 17:58:58 +0200, Torsten Imig <tor...@imig.de>
wrote:

Try to execute this from the command line:
onlineoffline = 'offlin';
onlineoffline == 'online'

== compares character by character and only works if the strings have
equal length (just for normal vectors/arrays).

Use strcmp for string comparisons:
if strcmp(onlineoffline, 'online')
% bla bla bla
end

Lars

Lars Gregersen
www.rndee.dk
l...@rndee.dk

Steven Lord

unread,
Jun 28, 2002, 1:39:25 PM6/28/02
to

"Lars Gregersen" <l...@rndee.dk> wrote in message
news:3d1c9c29...@news.cybercity.dk...

> On Fri, 28 Jun 2002 17:58:58 +0200, Torsten Imig <tor...@imig.de>
> wrote:
>
> >i get this error:
> >Error using ==> ==
> >Array dimensions must match for binary array op.

*snip*

> Try to execute this from the command line:
> onlineoffline = 'offlin';
> onlineoffline == 'online'
>
> == compares character by character and only works if the strings have
> equal length (just for normal vectors/arrays).
>
> Use strcmp for string comparisons:
> if strcmp(onlineoffline, 'online')
> % bla bla bla
> end

For general comparisons of arrays, use ISEQUAL:

ISEQUAL True if arrays are numerically equal.
ISEQUAL(A,B) is 1 if the two arrays are the same size
and contain the same values, and 0 otherwise.

ISEQUAL(A,B,C,...) is 1 if all the input arguments are
numerically equal.

ISEQUAL recursively compares the contents of cell arrays and
structures. If all the elements of a cell array or structure
are numerically equal, ISEQUAL will return 1.

--
Steve Lord
sl...@mathworks.com


Peter Boettcher

unread,
Jul 5, 2002, 9:36:41 AM7/5/02
to
Torsten Imig <tor...@imig.de> writes:

A string is a matrix. A == B compares each element of A with each
element of B, and returns a third matrix C the same size as A and B,
where C(i) = 1 if A(i)==B(i).

If A and B are different sizes, this doesn't work, thus the error.

Bottom line, use strcmp for comparing strings. (help strcmp)

--
Peter Boettcher <boet...@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/

Hemanshi

unread,
Feb 22, 2011, 2:57:07 PM2/22/11
to
http://scgwww.epfl.ch/matlab/student_labs/2001/matlab_tools/lmultigauss.m

I downloaded this source code to embed in my project but it gives this error(Array dimensions must match for binary array op.) while running. Please suggest a solution to the same.

0 new messages