CSVread empty cells non zero
35 views (last 30 days)
I'm trying to change the default empty cell input for Matlab.
I need to read a csv file and output an array using csvread. I suspect that after it reads and puts it into the array it's already zero so can't read as empty?
function [A] =createanarray(filename, linestoskip)
A=csvread(filename,linestoskip); %read the file and skip the input number of lines
A(A<0)= NaN; %make no value NaN
A; %output A array
Raghunandan V on 19 Mar 2019
Hi, The answer is simple. You try with xlsread
[A, B, C ] = xlsread('Data.xlxs');
Here A gives all the numbers of the matrix.
So if there is a cell with no numbers then it will return NaN. Even if there is a string or emptry cell it still returns NaN.