Why does the CSVREAD function not read in my data in MATLAB?
4 次查看(过去 30 天)
显示 更早的评论
The following data file is not read correctly by the CSVREAD function:
1, 2, 3, 4
5, 6
When I use CSVREAD to read in this data file, I receive the following output:
Warning: Input arguments must be scalar.
> In dlmread>cell2array at 204
In dlmread at 145
In csvread at 45
??? Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.
However, if I press Enter after the '6' in the text file, the file is read in with no problem and returns the expected data:
ans =
1 2 3 4
5 6 0 0
Why does this happen?
采纳的回答
MathWorks Support Team
2009-6-27
This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
This is a bug in the way CSVREAD handles text without the same number of elements in each row when there is no terminating carriage return. To work around the problem, insert the carriage return at the end of the data file.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!