MATLAB: How to compare 2 double array

digital image processingimageimage acquisitionimage analysisimage processingimage segmentation

Suppose i have 4 double array a(i,j) of size 256*8 elements and y(i1,j1),z(i2,j2) and b(i3,j3)having size of 1*8,1*8,1*50 elements.
I want to compare all the rows of a(i,j) with y(i1,j1),z(i2,j2) and b(i3,j3). The condition is
if (a(i,j)==y(i1,j1) or a(i,j)==z(i2,j2)) and b(i)==0
a(i,j)=y(i1,j1);
elseif b(i)==1
a(i,j)=z(i2,j2);
can anybody write the code perfectly.

Best Answer

I see nothing inherently wrong with your code other than using "and" and "or" for && and . And not having an "end" on your if/else block of course. Fix those problems and I think it should work with numbers that are integers or powers of 2. Of course your indexes i, j, i1, j1, i2, j2, i3, and j3 all need to be defined of course, perhaps in a for loop or whatever.
If you have fractions (non-integers and not inverse powers of 2), then see the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F