convert a .mat to excel file

조회 수: 68 (최근 30일)
mehra
mehra 2024년 4월 2일 14:54
답변: KSSV 2024년 4월 4일 4:58
Hello, I have so many .mat files that I want to convert them to excel.
the first one (If I want to do one by one) name is A_Q1S1.mat.
What is the correct code for that?
  댓글 수: 4
mehra
mehra 2024년 4월 2일 15:54
My .mat data names are like :
A_Q1S1
A_Q1S2
A_Q1S3
A_Q2S1
A_Q2S2
A_Q2S3
A_Q3S1
A_Q3S2
A_Q3S3
the same is for B and C.
Should I do something more for the whole files?
Mathieu NOE
Mathieu NOE 2024년 4월 3일 9:23
ok , we don't need any special approach for loading your different mat files
but what we miss here is :
  • what data you have stored in the mat files ,
  • which elements you want to export to excel
if you could share a couple of mat files ,that would be great

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

답변 (1개)

KSSV
KSSV 2024년 4월 4일 4:58
matFiles = dir('*.mat') ;
N = length(matFiles) ;
T = table;
for i =1:N
load(matFiles(i).name) ;
T.(i) = val ; % I assume each mat file has a variable "val" which is single column of same size
end
writetable(T,'Test.xlsx')

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by