matlab - Read multi format data in Octave -
i have started learning octave , trying read csv file comprising of data in form of string, integer , float. example shown below
a,b,c,d 1,c,10,1234.2 e,2,4,5 i tried lot using csvread. of examples below:
[val1, val2, val3, val4] = csvread('input.csv', '%s %s %s %s'); but getting error error: dlmread: error parsing range
then using question, made use of textread function shown below:
[val1, val2, val3, val4] = textread('input.csv', '%s %s %s %s', 'delimiter', ','); i able read data now, when print values, getting address of values shown below.
val1 = { [1,1] = [2,1] = 1 [3,1] = e } please can me in
1) finding out wrong in csvread.
2) why textread function returning addresses. how avoid them?
thanks in advance help.
the use of dlmread, cause of error, can found in answer. note that
x = csvread (filename, dlm_opts) is equivalent to
x = dlmread (filename, "," , …) the item returned textread
val1 = { [1,1] = [2,1] = 1 [3,1] = e } is cell array of strings. cell arrays used, matrix must composed of vectors of equal length, not case, when 1 operates 1 words of variable size. if 1 have stored words in matrix, rows/columns have had "padded", long longest word stored.
to convert element @ specific index of cell array (val1) vector employ cell2mat
vec=cell2mat(val1(index));
Comments
Post a Comment