How to plus two nan matrix
Ältere Kommentare anzeigen
If my two matrix are
a=3*3,b=3*3,c=3*3
a=[1 2 3,4 5 nan,7 nan 9]
b=[nan 3 3,4 5 6,nan 8 9]
c=a+b
Is that possible that c=[1 5 6,8 10 6,7 8 18]
How to calculate?
Thanks
Akzeptierte Antwort
Weitere Antworten (2)
Paulo Neto
am 28 Nov. 2018
0 Stimmen
3 Kommentare
James Tursa
am 28 Nov. 2018
Did you mean element-wise division? c = (a+b)./b
Paulo Neto
am 28 Nov. 2018
I'm considering a and b as arrays:
a=3*3,b=3*3,c=3*3
a=[1 2 3,4 5 nan,7 nan 9]
b=[nan 3 3,4 5 6,nan 8 9]
To calculate c = a + b, I'm using your routine:
c(isnan(c)) = a(isnan(c));
c(isnan(c)) = b(isnan(c));
and results in c=[1 5 6,8 10 6,7 8 18]
But I need to calculate: (a+b)./b, can I use the same method?
James Tursa
am 28 Nov. 2018
What would you want the individual result to be if "a" is NaN, and if "b" is NaN?
Paulo Neto
am 28 Nov. 2018
0 Stimmen
I'm considering a and b as arrays:
a=3*3,b=3*3,c=3*3
a=[1 2 3,4 5 nan,7 nan 9]
b=[nan 3 3,4 5 6,nan 8 9]
To calculate c = a + b, I'm using your routine:
c(isnan(c)) = a(isnan(c));
c(isnan(c)) = b(isnan(c));
and results in c=[1 5 6,8 10 6,7 8 18]
But I need to calculate: (a+b)./b, can I use the same method?
Kategorien
Mehr zu Calendar finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!