How to change the contents of an exported .mat file to an Excel file
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I wrote a code that converts two .mat files into Excel files from the selected selection of a list named Log. The code is as follows:
function Log_Callback(hObject, eventdata, handles)
g=get(handles.Log,'value')
if (g~=1)
x=get(handles.Log,'String');
y=get(handles.Log,'value');
f=x{y};
if(strcmp(f,'Exchange between FT0 and FT1 "Boolean"'))
set_param('MAJ','SimulationCommand','stop');
stop(handles.t);
set(handles.Stop,'BackgroundColor', 'red');
data=load('FT1Exchange(1).mat');
h=fieldnames(data);
for k=1:size(h,1)
xlswrite('testFT1.xlsx',data.(h{k}),h{k})
end
winopen testFT1.xlsx
elseif(strcmp(f,'Exchange between FT0 and FT1 "Double"'))
set_param('MAJ','SimulationCommand','stop');
stop(handles.t);
set(handles.Stop,'BackgroundColor', 'red');
data=load('FT1Exchange(2).mat');
h=fieldnames(data);
for k=1:size(h,1)
xlswrite('testFT11.xlsx',data.(h{k}),h{k})
end
winopen testFT11.xlsx
end;
end;
I have two questions:
1- The following code converts both .mat into two separate Excel files, how can I insert both .mat into two sheets of the same Excel file?
2- I get as a result the following table:
How can I add a column at the beginning that includes the name of each line?
Thank you for your Help
0 件のコメント
採用された回答
Tim Berk
2017 年 9 月 19 日
According to the documentation, you can write to excel using
xlswrite(filename,A,sheet,xlRange)
So that should give you everything you need (sheet and range).
This code creates an excel file that does this:
A = [0 1 0 1 0 1];
B = [1 1 1 0 0 0];
xlswrite('xls_file.xlsx',A,'sheet_A','B1')
xlswrite('xls_file.xlsx','A','sheet_A','A1')
xlswrite('xls_file.xlsx',B,'sheet_B','B1')
xlswrite('xls_file.xlsx','A','sheet_A','A1')
Let me know if that helps.
Cheers, Tim
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!