From: arhan on
Hi,

I have a code in which there are two inputs a and b. The code goes like this


if (a==1 && b==0)
T=array1;
end

if (a==0 && b==1)
T=array2;
end

array1 and array2 are two arrayas with lengths 62 and 66
I am getting the mismatch error "size mismatch (size [62*1]~=size [66*1])"
From: us on
"arhan " <arhan_yaqub(a)yahoo.com> wrote in message <i0f6bi$s7a$1(a)fred.mathworks.com>...
> Hi,
>
> I have a code in which there are two inputs a and b. The code goes like this
>
>
> if (a==1 && b==0)
> T=array1;
> end
>
> if (a==0 && b==1)
> T=array2;
> end
>
> array1 and array2 are two arrayas with lengths 62 and 66
> I am getting the mismatch error "size mismatch (size [62*1]~=size [66*1])"

well... this error certainly does not come from your code snippet...
show the whole story...

us
From: Oleg Komarov on
"arhan " <arhan_yaqub(a)yahoo.com> wrote in message <i0f6bi$s7a$1(a)fred.mathworks.com>...
> Hi,
>
> I have a code in which there are two inputs a and b. The code goes like this
>
>
> if (a==1 && b==0)
> T=array1;
> end
>
> if (a==0 && b==1)
> T=array2;
> end
>
> array1 and array2 are two arrayas with lengths 62 and 66
> I am getting the mismatch error "size mismatch (size [62*1]~=size [66*1])"

Your problem is linked with the size of a and b (which of course is not obvious from you post).
Without further details on what you're trying to accomplish I can't give any other advice.

Oleg
From: arhan on
well, sorry i forgot to mention. the code is actually inside an "embedded matlab function" in a simulink model.. a and b are its input ports and can take values of 1 or 0. while T is an array inside the embedded matlab fcn. output Y is not T.

function Y = fcn(a,b)

array1=[1 2 3 4 5];
array2=[1 2 3 4 5 6 7 8];
T=[];

if (a==1 && b==0)
T=array1;
end

if (a==0 && b==1)
T=array2;
end
.........
.......
Y=....
From: Oleg Komarov on
"arhan " <arhan_yaqub(a)yahoo.com> wrote in message <i0f994$83c$1(a)fred.mathworks.com>...
> well, sorry i forgot to mention. the code is actually inside an "embedded matlab function" in a simulink model.. a and b are its input ports and can take values of 1 or 0. while T is an array inside the embedded matlab fcn. output Y is not T.
>
> function Y = fcn(a,b)
>
> array1=[1 2 3 4 5];
> array2=[1 2 3 4 5 6 7 8];
> T=[];
>
> if (a==1 && b==0)
> T=array1;
> end
>
> if (a==0 && b==1)
> T=array2;
> end
> ........
> ......
> Y=....
As us said these lines of code alone won't throw that error unless size(a) ~= size(b).
Check that a and b are always scalars.
use: dbstop if error
after you finish use: dbclear if error
(See debugging for more details)

Oleg