Load command for giving input from text file?

5 ビュー (過去 30 日間)
RS
RS 2013 年 8 月 9 日
**** 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?

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 8 月 9 日
You cannot input that using the load() command. You will need to use uiimport() or textscan()

David Sanchez
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';

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by