Hi Nasser,
Thanks for the info. Like you, I do not get an error when I run it in the workspace, but I do get the error when I try to run it in a function. I have checked the sizes, etc. and they all seem to be correct. It is very weird. I am running Matlab on the Mac. I wonder if it is some kind of bug with that version?
Thanks again for the help.
Russ
"Nasser Abbasi" <nma@12000.org> wrote in message <UBHPl.7189$Lr6.2786@flpi143.ffdc.sbc.com>...
>
> "Russ Branaghan" <russ.branaghan.nospam@asu.edu> wrote in message
> news:guneuu$42k$1@fred.mathworks.com...
> > Hello All,
> >
> > I get a matrix dimensions must agree error when I try the following code
> > in a function, but as far as I can tell the dimensions do agree. They are
> > both 1 x 12 arrays. Any ideas?
> >
> > Thanks,
> >
> > Russ
> >
> > Here is the code:
> > hmhp=sum((mean(x) > median(mean(x))) & (mean(y) >median(mean(y))));
> >
> > And here is the error:
> > ??? Error using ==> and
> > Matrix dimensions must agree.
> >
> > Error in ==> getc2 at 13
> > hmhp=sum((mean(x) > median(mean(x))) & (mean(y)
> > >median(mean(y))));
>
> I get no error:
>
> x=rand(1,12)
> y=rand(1,12)
> hmhp=sum((mean(x) > median(mean(x))) & (mean(y) >median(mean(y))))
>
> You have something else wrong. do size on x and y, and do 'which all' on
> mean, median, sum to make sure you are using Matlab functions and not your
> own.
>
> good luck
> Nasser
>
