MATLAB: Help with isnan with two matrices of unequal dimensions

isnan; matrices of unequal dimension

Hi,
I have two matrices of unequal dimensions. pol1 = 1 x 22648 and pol2 has dimensions of 1 X 22706.
I wanted to plot one against the other and I want to check the cells for which both values exist.
I tried good_use=find(~isnan(pol1) & ~isnan(pol2))
but I get an error ' Matrix dimensions must agree '.
How do I solve this error ?

Best Answer

"yes use shorter vectors"
So in effect, you're telling us to truncate the longer one so that it is the same length as the other? If you do that then your initial expression will work.
%truncate longer vector to the size of the shorter vector:
veclength = min(numel(po1), numel(pol2));
pol1 = pol1(1:veclength);
pol2 = pol2(1:veclength);
%your original search, find not needed
good_use = ~isnan(pol1) & ~isnan(pol2)
%plot
plot(pol1(good_use), pol2(good_use))