Reading in a text file and creating multiple arrays

조회 수: 2 (최근 30일)
Benjamin
Benjamin 2019년 3월 7일
댓글: Benjamin 2019년 3월 7일
I have a large text file. The first two lines appear as follows:
// cor=0.2 n=4000 N=10000
// r u_effe averg
Below that I have a bunch of lines of text with 4 columns. Then after the block of code finishes, I have 2 blanks lines, and then another 2 lines of code as above, but with cor=0.3. This goes on and on. Can I load this txt file into MATLAB and break up these into arrays with the different arrays named cor-0.2, cor-0.3 etc?
I have attached some sample code

답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 7일
  댓글 수: 4
Benjamin
Benjamin 2019년 3월 7일
I just put the data into excel. Is there a way that I can load each worksheet into MATLAB and store each as a separate array? I ultimately want to be able to loop through them.
Benjamin
Benjamin 2019년 3월 7일
I think I got it:
[~,sheet_name]=xlsfinfo('filename.xlsx');
for k=1:numel(sheet_name)
data{k}=xlsread('filename.xlsx',sheet_name{k});
end;

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by