필터 지우기
필터 지우기

Dataset loop and iteration

조회 수: 3 (최근 30일)
Emrys
Emrys 2018년 1월 17일
댓글: Emrys 2018년 1월 18일
Hi, i have a problem with file.txt loop. I have to plot a series of datasets in different files (60). Is it possible to iterate the same procedure for each file in order not to define 60 variables? each dataset have different rows and columns numbers. Is it possible?
  댓글 수: 1
Kaushik Lakshminarasimhan
Kaushik Lakshminarasimhan 2018년 1월 17일
Yes, you need to create an a array of filenames and then use it to load them one by one. You don't have to manually define the array, you can use the dir function.

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

채택된 답변

KSSV
KSSV 2018년 1월 18일
files = dir('*.txt') ; % all the text files in the folder
N = length(files) ; % Total number of files
% loop for each file
for i = 1:N
thisfile = files(i).name ;
% load the file
% do what you want
end
  댓글 수: 1
Emrys
Emrys 2018년 1월 18일
Hi, thank you very much, but i have a problem when i load each file. thisfile is 1x1 element, i expected to be Nx1 how can i work with the (i)th file from the code you built? I mean, i want to plot one of all . How can i get this?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by