Read blank row as 0
1 次查看(过去 30 天)
显示 更早的评论
What function in MATLAB can I use that reads an excel line and plots 0 when it has a blank space
0 个评论
回答(1 个)
Matt Fig
2012-9-26
Blank rows are read as nans with xlsread. So use
N(isnan(N))=0
3 个评论
Matt Fig
2012-9-26
N is the output from xlsread, assuming you have numeric data. See the help for xlsread.
help xlsread
Image Analyst
2012-9-27
N = xlsread(filename);
Where there is a blank cell in the Excel worksheet, N will be NaN at those locations, and N will have valid numbers at other locations where you have valid numbers in the worksheet. Matt's code changes those matrix locations with NaN's in them from NaN to 0, as you requested. Understand?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!