Load command for giving input from text file?

**** ASCII File [Tue Aug 06 11:44:56 2013]
Column 1: X Axis
Column 2: Y
2.079480 0.967031
2.080320 0.966973
2.081150 0.966570
2.081990 0.966362
2.082830 0.966502
2.083660 0.966670
2.084500 0.966470
2.085340 0.966484
2.086180 0.966465
2.087020 0.966699
This is text file how can I input only number to matlab using load command?

Answers (2)

You cannot input that using the load() command. You will need to use uiimport() or textscan()
This example may be of help (taken from documentation):
x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp.txt', 'w');
fprintf(fid, '%6.2f %12.8f\n', y);
fclose(fid);
% method 1
load('exp.txt') %And you end up with a variable (matrix) called _exp_ holding your data
%method 2:
% Read the data, filling A in column order
% First line of the file:
% 0.00 1.00000000
fid = fopen('exp.txt');
A = fscanf(fid, '%g %g', [2 inf]);
fclose(fid);
% Transpose so that A matches
% the orientation of the file
A = A';

Tags

Asked:

RS
on 9 Aug 2013

Community Treasure Hunt

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

Start Hunting!