How can i get the data from 3D graph to excel sheet
Show older comments
I try to get the data from wav file to excel sheet. I can to manage to get the data from wav file to graph of FFT analysis. But I need to get the data into excel sheet, so i can easily check and present it. I try these line of program, but the data coming on excel is not understandable. I need the data coming is on 3 columns only based on my graph, which is: time vs frequency vs power/freq
1 Comment
eko setiawan
on 22 Jun 2016
Answers (1)
Nihar Deodhar
on 28 Jun 2016
0 votes
I see that you have a matlab fig file finally after you process the wav file and extract the data.
Assuming that you have a three dimensional plot, this is how you could export the data into an excel file.
%% Change working directory to where the figure is
filepath = ('C:\Users\enter_full_path_here');
cd(filepath)
% Change your_figure_name below to your actual figure name
openfig('your_figure_name.fig','reuse'); % open figure
ax1 = gca; % get handle to axes of figure
fig1 = get(ax1,'Children'); %get handle to all the children in the figure
X = get(fig1,'XData'); %get individual axes data
Y = get(fig1,'YData');
Z = get(fig1,'ZData');
% Create an excel spreadsheet and tabulate the data in columns
filename = 'file_name.xlsx';
titles = {' Time ',' Frequency ','Power'};
xlswrite(filename,titles,1,'A1');
xlswrite(filename,X',1,'A2');
xlswrite(filename,Y',1,'B2');
xlswrite(filename,Z',1,'C2');
% transpose all the data as you want columns instead of rows
% Save the file
full_file_path = fullfile(filepath, filename);
hExcel = actxserver('Excel.Application');
hWorkbook = hExcel.Workbooks.Open(full_file_path);
hWorksheet = hWorkbook.Sheets.Item(1);
% Select the entire spreadsheet.
hExcel.Cells.Select;
% Auto fit all the columns.
hExcel.Cells.EntireColumn.AutoFit;
% Center align the cell contents.
hExcel.Selection.HorizontalAlignment = 3;
hExcel.Selection.VerticalAlignment = 2;
% Put "cursor" or active cell at A1, the upper left cell.
hExcel.Range('A1').Select;
hWorkbook.Save
hWorkbook.Close
hExcel.Quit
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!