Replacing NaN cell array values with empty values
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I've tried to figure this out (and looked at past forum posts) but I haven't been able to determine how to replace NaN values in a cell array with an empty/NULL value while retaining the size of the cell array. For example:
A=[8 10 5 -9 NaN];
A=transpose(A);
A=num2cell(A);
A(5,1)='';
This code ends up deleting the 5th element so that my array is now 4x1.
The background for why I'm trying to do this is that I'm exporting a number of different series into an Access database and I want each series to be of the same length. Unfortunately Access won't let me accomplish this by exporting NaNs and numbers into the database because it doesn't accept mixed data types. So I'm trying to find a way to keep the size of each series the same by replacing the NaNs w/ something that Access will treat as a null value (of course open to any other ideas to accomplish my ultimate objective).
Thanks,
JK
0 commentaires
Réponse acceptée
Guillaume
le 2 Déc 2014
Modifié(e) : Guillaume
le 2 Déc 2014
You need to understand the difference between {} and () indexed when using cell array.
{} returns the content of the indexed cell(s). It is of the same type as whatever is in the cell
() returns the cell(s) themselves. It always is a cell array.
Therefore
A(5,1) = []; %or A(5,1) = '';
deletes the cell,
A{5,1} = []; %or A{5,1} = '';
replaces the content of the cell by an empty matrix.
Plus de réponses (1)
Azzi Abdelmalek
le 2 Déc 2014
Modifié(e) : Azzi Abdelmalek
le 2 Déc 2014
A=[8 10 5 -9 NaN];
A=transpose(A);
A=num2cell(A)
A{5,1}=' '
%or better
A{5,1}=[]
0 commentaires
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!