Read blank row as 0

What function in MATLAB can I use that reads an excel line and plots 0 when it has a blank space

Risposte (1)

Matt Fig
Matt Fig il 26 Set 2012

1 voto

Blank rows are read as nans with xlsread. So use
N(isnan(N))=0

3 Commenti

Rodrigo Trigona
Rodrigo Trigona il 26 Set 2012
Sorry,I didn't understand how can I use this to read the blank spaces as 0.
N is the output from xlsread, assuming you have numeric data. See the help for xlsread.
help xlsread
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?

Accedi per commentare.

Richiesto:

il 26 Set 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by