Replace zeros with NaN's - when there are already NaN's in the matrix?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
I have a large square matrix which is made up of smaller square matrices which have some NaN values. I used 'blkdiag' to combine the matrices diagonally and all the gaps were filled in with zeros.
I now wish to replace all of the zeros in the large matrix (F) with NaN's.
I tried F(find(~F))=NaN but I get an error saying NaN's cannot be converted to logicals, which makes sense but now I'm not sure how I can get round it. I am fairly new to Matlab.
Any help would be much appreciated.
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 9 Jun. 2011
No reason for find and you can't convert nans to logicals.
F(F==0) = nan;
Weitere Antworten (2)
Ivan van der Kroon
am 9 Jun. 2011
Change to double first:
F=double(F);
F(find(~F))=NaN;
Just curious; why would you need this?
1 Kommentar
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!