필터 지우기
필터 지우기

combine 30.mat file having 1*15 matrix (Each .mat file having 1 row and 15 columns) to one .mat file

조회 수: 1 (최근 30일)
Hallo ,
I have a .mat files of 30 with 1*15 matrix, I want to combine all these 30 files to one .mat file with 1*450 matrix. Can you please help me with how to do this steps.
I have done and tried many of the examples with the existing codes in Mathwork but couldnot make it to work.
Can any one help me.
I have attached 6 .mat files as a reference.
Thankyou in advance

채택된 답변

Stephen23
Stephen23 2020년 2월 25일
편집: Stephen23 2020년 2월 25일
The best approach is to follow the examples in the MATLAB documentation:
N = 30;
C = cell(1,N); % preallocate
for k = 1:N
F = sprintf('Si_%u.mat',k);
S = load(F);
C{k} = S.Si; % using the same field/variable name = very good data design!
end
M = [C{:}]; % concatenate
save('Si.mat','M')
See also:
  댓글 수: 3
Stephen23
Stephen23 2020년 2월 25일
편집: Stephen23 2020년 2월 25일
"It is not in image format..."
Nothing in my answer is related to images, so what is your comment related to?
"Actually in the .mat file the variable which contains matrix 1*13 the name of the variable is also Si"
Yes I know, because I looked at the contents of all of your sample files before writing and testing my code.
"there is no path provided how can i use this code to carry on with different .mat files."
My code already works with multiple .mat files in the current folder. I know this because I tested it.
You did not specify the lcoation of the files, but if you want to import the files from other location then simply add fullfile to generate the correct absolute/relative filename.
Or simply change the current directory.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by