Kindly any one help me regarding MATLAB GUI guide execution of my research work?

1 view (last 30 days)
I have created MATLAB GUI for my project. I want to display the absolute values of energy in audio on gui and resulting audio graph also on GUI. But Im getting results on MATLAB command prompt and its displaying separate figures but not on GUI axes?
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear('all');
close('all');
[f,fs] = audioread('ias.wav');
N = size(f,1); % Determine total number of samples in audio file
figure; hold
subplot(2,1,1);
plot(1:N, f(:,1));
title('Left Channel');
subplot(2,1,2);
plot(1:N, f(:,1));
title('Right Channel');
n = 2;
fprintf('The sum of the absoulte values (Before filtering) is: \n');
fff = fft(f);
h = sum(abs(fff));
max(f)
disp(h)
beginFreq = 700 / (fs/2);
endFreq = 1600 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'bandpass');
fOut = filter(b, a, f);
% Construct audioplayer object and play
%p = audioplayer(fOut, fs);
%p.play;
fprintf('The sum of the absoulte values (After filtering) is: \n');
figure;
plot(filter(b, a, f))
ggg = fft(f);
h = sum(abs(ggg));
disp(h)
fprintf('Sampling Frequency is: \n');
disp(fs)

Answers (1)

Steven Lord
Steven Lord on 13 Jun 2021
If you want to plot into an axes in your GUI, why are you explicitly creating a new figure?
figure; hold
Current plot held
Specify the handles of the axes in your GUI as the first input when you call plot to make plot put the line(s) it creates in that axes.
h(1) = subplot(3, 1, 1);
h(2) = subplot(3, 1, 2);
h(3) = subplot(3, 1, 3);
v = 1:10;
plot(h(2), v, v.^2) % Plot into the second axes

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!