loading a two dimensional data from a file

1 view (last 30 days)
how to upload data from a file of 2 dimensional with columns varying for each row using matlab.yhe variables are floating points.so if i am storing it in cell array even . and space between two values is occupying memory.wastage of memory
  4 Comments
annamaneni sriharsha
annamaneni sriharsha on 19 Mar 2014
no there is no fixed maximum number of columns per line.there are no o and NaN in the data and regarding values that are not present i didnt understand the question
annamaneni sriharsha
annamaneni sriharsha on 19 Mar 2014
Edited: Walter Roberson on 19 Mar 2014
@akshat i want to upload two dimensional as it is from any kind of file.in the file tha data is stored as
10.53 10.00 11.20 11.222 11.222 11.245
10.53 10.00 11.20 11.222 11.222
10.53 10.00 11.20 11.222 11.222
10.53 10.00 11.20 11.222 11.222 11.245
10.53 10.00 11.20 11.222 11.222 11.245
10.53 10.00 11.20 11.222 11.222 11.245
10.53 10.00 11.20 11.222
so how to upload as it is the data so that i can implement algorithms on the data

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 19 Mar 2014
indata = {};
while true
linein = fgetl(fid);
if ~ischar(linein); break; end
indata{end+1} = sscanf(linein, '%g');
end

Community Treasure Hunt

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

Start Hunting!