I am now using CSVREAD to import csv datas ,some of the datas are as follows The first line of CSV is head line and my matlab scrip is
m11=csvread('SPC.csv',2,0); However sometimes, MATLAB terminate with errors saying " Error using dlmread (line 139) Empty format string is not supported at the end of a file.
Error in csvread (line 48) m=dlmread(filename, ',', r, c);
Error in MAIN_WB_DYNA_ANASIS (line 68) af=csvread('DISNODE.csv',2,0);
time,114059, 0,0, 0.00096509,-6.4337e-011, 0.00193018,-8.5843e-010, 0.0029757,-4.1747e-009, 0.00394079,-1.1399e-008, 0.0049863,-2.5976e-008, 0.00595139,-4.7814e-008, 0.0069969,-8.3311e-008, 0.00796199,-1.2971e-007, 0.00892709,-1.9175e-007, 0.0099726,-2.7931e-007, 0.0109377,-3.8154e-007, 0.0119832,-5.1866e-007, 0.0129483,-6.7264e-007,
No products are associated with this question.
... The first line of CSV is head line ...
Per the help file for csvread,
M = csvread('FILENAME') reads a comma separated value formatted file FILENAME. The result is returned in M. The file can only contain numeric values.
Note the last sentence above--if there's a header line, you can't use csvread (or dlmread, either, as you can observe from the error message that the former is just a wrapper around the latter.
Use importdata or textscan or even textread instead...
importdata will automagically try to determine the number of header line(s); use the 'headerline' named argument in the textXXX routines.
You probably have a blank line at the end of your input file or your input file uses a newline character from a different operating system such as OS X or Windows. The way you skip the headers by beginning the read on line 2 should work fine.
Play games and win prizes!Learn more