Load command for giving input from text file?

조회 수: 10 (최근 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 CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by