Replacing NaN cell array values with empty values
19 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Guillaume
2014 年 12 月 2 日
編集済み: Guillaume
2014 年 12 月 2 日
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.
その他の回答 (1 件)
Azzi Abdelmalek
2014 年 12 月 2 日
編集済み: Azzi Abdelmalek
2014 年 12 月 2 日
A=[8 10 5 -9 NaN];
A=transpose(A);
A=num2cell(A)
A{5,1}=' '
%or better
A{5,1}=[]
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!