Export several arrays with the same name to a xls

조회 수: 1 (최근 30일)
lightworks . 2013년 6월 24일
I have a lot of *.mat, each one containing 3 arrays of the same name, that is:
  • file1.mat contains arrays A1, A2 and A3
  • file2.mat contains arrays A1, A2 and A3 ... and so on.
I need to export them to a xls, like this:
  • Sheet 1 containing, side by side, all the arrays named by A1
  • Sheet 2 containing, side by side, all the arrays named by A2
  • Sheet 3 containing, side by side, all the arrays named by A3
I've been trying for hours now and I can't make it work (my problem is the repeated array's name).
I loaded all the files with this (I don't even know if it's the right way):
s = what('./matrices/Tmax/');
for i=1:numel(matfiles);
x=load(['./matrices/Tmax/' char(matfiles(i))]);
I'd really appreciate any help. Thanks in advance!

채택된 답변

Leah 2013년 6월 24일
This will work up to the Z column in Excel (26 mat files) I don't know how many mat files you have.
mat_files=1:26; %number of mat files
excel_col=double('A'); %starting Excel Column
for m=mat_files
load(['file' num2str(m) '.mat']);
  댓글 수: 2
Leah 2013년 6월 24일
Your modification is correct and the code works for me. Must be something specific to your data. My dummy data is just a bunch of numbers. Check out this info for possible solutions to that error code.

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

추가 답변 (0개)


Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by