Vector concatenation in MATLAB GUIDE using sample selection provided by input dialog
Mostra commenti meno recenti
Hello,
I am trying to use vertcat to concatenate audio samples selected from a wav file specified by an input dialog. I am able to select one sample using input from the dialog and to add that to the vector, but rather than adding subsequent selected samples to the end of the vector, it overwrites the existing values. Please can anyone spot what i am doing wrong? Both the input dialog and the concatenating of the vector are activated using push buttons in the GUI. The code for both buttons is as follows:
Many Thanks Andy
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sampleTemp;
y = handles.y;
sampleLoc = handles.sampleLoc;
prompt = {'Enter sample start:','Enter sample end:'};
dlg_title = 'Enter values';
num_lines= 1;
def = {'1','2'}; %default
answer = inputdlg(prompt,dlg_title,num_lines,def);
A = getfield(answer,{1}); %first input field
A = str2double(A);
B = getfield(answer,{2}); %second input field
B = str2double(B);
sampleTemp = y(sampleLoc(A):sampleLoc(B));
handles.sampleTemp = sampleTemp;
guidata(hObject, handles);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
sampleTemp = handles.sampleTemp;
sample1 = handles.sample;
sample1 = vertcat(sample1, sampleTemp);
clear sampleTemp;
length(sample1) %used to test length of vector
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Code Execution in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!