필터 지우기
필터 지우기

import a text file into a variable

조회 수: 29 (최근 30일)
Ahmed Nabil
Ahmed Nabil 2017년 9월 17일
댓글: M.S. Khan 2020년 8월 25일
Hello,
I have the attached text file and I want to import it and put it into a matrix variable
what is the simplest function to do the work?
  댓글 수: 2
Cedric
Cedric 2017년 9월 17일
What have you tried so far?
Ahmed Nabil
Ahmed Nabil 2017년 9월 18일
I tried to use this function but didn't work
https://www.mathworks.com/help/matlab/ref/readtable.html

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2017년 9월 18일
doc load, importdata.
  댓글 수: 1
M.S. Khan
M.S. Khan 2020년 8월 25일
How, could u plz explain

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Guillaume
Guillaume 2017년 9월 18일
편집: Guillaume 2017년 9월 18일
I tried to use this function but didn't work.
Utterly useless statement.
>> t = readtable('Uz.txt', 'ReadVariableNames', false);
>> summary(t)
Variables:
Var1: 109×1 double
Values:
Min 3.9152
Median 6.5121
Max 11.463
Clearly works.
If "it didn't work" then you need to provide the exact code you've used and the exact error code you get otherwise we have no idea why "it didn't work".

KL
KL 2017년 9월 18일
data = readtable('Uz.txt');
or for just one column,
data = textread('Uz.txt')

Jan
Jan 2017년 9월 18일
What exactly is "simple"?
fid = fopen(FileName, 'r');
if fid == -1
error('Cannot open file: %s', FileName);
end
Data = fscanf(fid, '%g', inf);
fclose(fid);
Here "simple" means, that reading the documentation of the commands can be done quickly. textscan might look easier in the code, but you have much more options and reading the docs needs more time in consequence.

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by