I want to make a GUI in matlab that has 2 buttons. 1 Button (pushbutton1) loads the selected file and the second button (pushbutton2) executes a code. This is what i have so far
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, ventdata, 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) [filename pathname] = uigetfile({'*.wav'}, 'Select File'); fullpathname = strcat (pathname, filename); audio = wavread(fullpathname); % --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % get a section of vowel [x,fs]=wavread('audio',[24120 25930]); ms20=fs/50; % minimum speech Fx at 50Hz % plot waveform t=(0:length(x)-1)/fs; % times of sampling instants subplot(2,1,1); plot(t,x); legend('Waveform'); xlabel('Time (s)'); ylabel('Amplitude');
The mistake is in the following line
[x,fs]=wavread('audio',[24120 25930]);
How should I write it?
Also when plotting how do I make the plot appear on the GUI ?
.wav
extension to the filename. Also, when you create the GUI you will create a figure window, so just add an axes to it using theaxes
command, then the plot will appear in that. – David