Load command for giving input from text file?
2 次查看(过去 30 天)
显示 更早的评论
**** 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?
0 个评论
回答(2 个)
Walter Roberson
2013-8-9
You cannot input that using the load() command. You will need to use uiimport() or textscan()
0 个评论
David Sanchez
2013-8-9
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';
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!