Using cellfun to remove nans from uniform cell
Afficher commentaires plus anciens
Hi Guys, I have a bunch of cell values continaing 17 unifrom sized matrices that have NaN values in them. I need to replace these NaNs with any large place-holder number. I am trying to use a solution that has shown up in other posts:
https://www.mathworks.com/matlabcentral/answers/440856-replacing-nans-with-zero-in-a-matrix-within-a-cell-array
https://www.mathworks.com/matlabcentral/answers/459133-how-to-replace-nan-values-with-any-other-values-in-a-cell-array
Here is my code
RvarNnan1 = cellfun(@(M) subsasgn(M, substruct('()', {isnan(M)}), 123000), RvarNnan1, 'UniformOutput', 123000);
I am getting the following errors, prior to running:
"output must be assigned to a variable"
and after running get :
"Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false."
I think i don't understand the "M" variable. I've attached my cell variable(this is a sliced version {5x1}, of the actual variable {17x1} due to upload size restraits. Also of note, different from the other posts, I am replacing the NaNs with a meaningless large number. I have tried switiching around M with a predifenedvariable as well as using the actual VarNnan1.
Any help here is greatly appreciated!
1 commentaire
James Spalding
le 19 Oct 2022
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!