I want to ignore nan values and substract others.
보은 이
on 13 Sep 2022
Latest activity Reply by Christopher Stapels
on 19 Sep 2022
I have a data.

And, I want to substract the data using for.
But, I want to ignore the nan values and substract others.
For example, [1, 2, 3, NaN, 6, 9, 12, 14] ---- substract---> [1, 1, 3, 3, 2]
How can I do this?
5 Comments
Time DescendingWhat is the expected answer? I'm not clear what you mean by subtract for arrays.
[1,2,3,6,9,12,14] - [ 1,1,3,3,2] =?
Here is how you can clean the nan values though:
A=[1, 2, 3, NaN, 6, 9, 12, 14];
AnoNan=A(~isnan(A));
B = [1, 1, 3, 3, 2];
BnoNan=B(~isnan(B));
Sign in to participate