"Readmatrix" function excluding non-numeric value if first on last in vector - Help
5 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I'm currently extracting sequences stored in a excel worksheet. These sequences represents the order in which data must be extract in other files. All columns are of the same length, for exemple 5 elements. Now the twist is that in some columns there are non-numeric terms such as 'n.a.', as for example in the '.xlsx' :

When using the readmatrix() function on the first line, the 'n.a.' is stored in the middle of the vector, the function returns a 1x5 vector with a 'NaN' value in the middle or at the first position as shown below :
readmatrix('Example.xlsx','Sheet','Feuil1','Range','A1:E1')
ans =
1 2 NaN 4 5
readmatrix('Example.xlsx','Sheet','Feuil1','Range','A3:E3')
ans =
NaN 2 3 4 5
However, if the number are stored in the other direction (as columns), the readmatrix() function ignores the 'n.a.' values stored first :

readmatrix('Example.xlsx','Sheet','Feuil2','Range','A1:A4')
ans =
1
2
3
4
readmatrix('Example.xlsx','Sheet','Feuil2','Range','C1:C4')
ans =
2
3
4
readmatrix('Example.xlsx','Sheet','Feuil2','Range','E1:E4')
ans =
1
2
3
NaN
Is there an logic behind this behavior or a way around this problem?
Thank youv very much.
1 件のコメント
dpb
2019 年 9 月 6 日
Try using the SpreadsheetImportOptions object to see if setting number of variables and type will help.
Otherwise, revert to readtable or xlsread that will return (optionally) the full raw cell values you can process.
Or, cleanup the Excel spreadsheet first by ensuring NaN numeric values or other missing value.
回答 (1 件)
Walter Roberson
2019 年 9 月 6 日
In that case it would be treated as a variable name field to be skipped.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!