Retrieving data from txt file.

3 ビュー (過去 30 日間)
sermet
sermet 2014 年 2 月 2 日
回答済み: mohamad basma 2016 年 5 月 11 日
%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 日
[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 classify num, txt1, raw like above example
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 2 日
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 日
[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?

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by