%I retrieve data from excel like that,
[FileName1,PathName] = uigetfile('*.xlsx','Select the excel file')
[num,txt1,raw] = xlsread(FileName1)
%I have a .txt file which I need to extract data from it so I need to apply this way to retrieve data from a .txt file. How can I do that.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 2일
편집: Azzi Abdelmalek 2014년 2월 2일

0 개 추천

[FileName1,PathName] = uigetfile('*.xlsx','Select the excel file')
[num,txt1,raw] = xlsread(fullfile(PathName,FileName1))
For a text file you cane use importdata

댓글 수: 5

sermet
sermet 2014년 2월 2일
I need to read txt file not xlsx file.
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 2일
For txt file, you need to know the format of your data in your txt file. Can you post a sample of your data?
sermet
sermet 2014년 2월 2일
points_id x y z
A 100 150 200
B 200 300 400
..
..
I want that users can choose the txt file and retrieve data from it like in my above example (xlsread)
sermet
sermet 2014년 2월 2일
I need to classify num, txt1, raw like above example
fid=fopen('file.txt')
a=textscan(fid,'%s %f %f %f','headerlines',2)
fclose(fid)
text1=a{1}
num=cell2mat(a(2:4))

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

추가 답변 (1개)

mohamad  basma
mohamad basma 2016년 5월 11일

0 개 추천

[FileName1,PathName] = uigetfile('*.xlsx','Select the excel file') [num,txt1,raw] = xlsread(fullfile(PathName,FileName1))
How can i get the data in a matrix from this function?

카테고리

도움말 센터File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

질문:

2014년 2월 2일

답변:

2016년 5월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by