필터 지우기
필터 지우기

Automatically create matrix names

조회 수: 2 (최근 30일)
Philip Hoskinson
Philip Hoskinson 2015년 7월 23일
댓글: John D'Errico 2015년 7월 23일
I'm using dir and dlmread to bring in files:
I want a loop that automatically creates matrixes on it's own, and assigns that data from my files to them.
example:
% 'a' is a struct array with file names, 'f' is folder location
for i = 1:numel(a)
(???) = dlmread(fullfile(f,a{i}),'',4,1)
end
Ex. Output
matrix1 = [data from file 1]
matrix2 = [data from file 2]
matrix3 = .....
In general is there a way to create matrixes, variable names etc. automatically using some type of command?...

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 23일
for i = 1:numel(a)
out{k}=dlmread(fullfile(f,a{i}),'',4,1)
end
  댓글 수: 2
Philip Hoskinson
Philip Hoskinson 2015년 7월 23일
편집: Philip Hoskinson 2015년 7월 23일
This creates one matrix - I actually need new matrixs to be generated automatically, and be able to sort through them.....
Start with nothing, run function that creates - say twenty matrixes automatically...
John D'Errico
John D'Errico 2015년 7월 23일
And you can trivially sort through a cell array of matrices! In fact, it is easier to work with a cell array of matrices than with a whole slew of differently named matrices.
Or if they are all the same size, then make a 3-dimensional matrix. That will be even easier to work with.
So the answer is, DON'T DO WHAT YOU WANT TO DO!

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

추가 답변 (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