Reputation: 141
I have notepad data like this:
-1 1:0.009 2:-0.056 3:6.009
The data is in rows and columns while every row starts with 1 or -1. When I try to access data in matlab, e.g:
data=load('*.txt')
X=data(1,:)
I will get -1 1 2 3
which represent the no. of data point not actual data, rather 0.009 0.056 6.009 which is actual data. Can anyone help me with this?
Upvotes: 1
Views: 145
Reputation: 5073
An alternative to a simple load
is to use fscanf
or textscan
, as in
fid=fopen('accessing_data_of_notepad.txt')
dat = textscan(fid,'%s')
fclose(fid)
Your data will be in cell array dat
. You can modify the format specifier to suit your needs, for instance if you want all of the numbers you can use something like
fid=fopen('accessing_data_of_notepad.txt');
dat = textscan(fid,'%d %d:%.3f %d:%.3f %d:%.3f')
fclose(fid);
Values 0.009 0.056 6.009
will be in dat{3}
, dat{5}
and dat{7}
Upvotes: 1