Borrar filtros
Borrar filtros

How can i get the data from 3D graph to excel sheet

2 visualizaciones (últimos 30 días)
eko setiawan
eko setiawan el 22 de Jun. de 2016
Respondida: Nihar Deodhar el 28 de Jun. de 2016
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 comentario
eko setiawan
eko setiawan el 22 de Jun. de 2016
these are the program:
clear all close all clc %% load data [filename,path] = uigetfile('*.wav','open sound'); if isequal(filename,0) return end figure('Name','Analisa Hasil Profile Ledakan ','NumberTitle','off') [data,Fs] = audioread(fullfile(path,filename)); %sound(data,Fs); time = 0:1/Fs:(length(data)-1)/Fs; subplot(1,2,1) plot(time,data) xlabel('time (s)') ylabel('Amplitude') axis tight grid on title('Sinyal Input') subplot(1,2,2) [S,F,T]=spectrogram(data,512,256,512,Fs); spectrogram(data,512,256,512,Fs,'yaxis'); view(-22,40) shading interp colorbar off title('Sinyal dalam Frekuensi (Hz)') pause(3) %% load data [filename,path] = uiputfile('*.xlsx','save data'); if isequal(filename,0) return end xlswrite(([path,filename]),S)

Iniciar sesión para comentar.

Respuestas (1)

Nihar Deodhar
Nihar Deodhar el 28 de Jun. de 2016
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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by