matlab - Disp difference between A and B when B is not NaN -
a have 2 matrices <1x100 double>
plot(a,b)
. in columns of matrix b there nan. want difference (like 5 higher b) between b both , b exists. want presented local maximum, printing out disp
.
example: when max(a) = 20 , b = 10 want display: 10 more b. when changes 30 once again want display: max(a) 20 more b.
help appreciated!
validdata = ~isnan(a) & ~isnan(b); % indices both exist plot(a(validdata),b(validdata));
isnan
gives elements nan
, negate (~
), , non-nan values. can used logical index both a
, b
.
to maximum values, andrasdeak suggests
nanmax(a-b)
update: apparently max
has default omit nan values, can use directly:
[maxvalue,maxposition] = max(a-b);
Comments
Post a Comment