robc20
Computer
- Feb 21, 2006
- 1
Hi, I've created a simple sound copy and paste M-file with GUI that will allow you to select a section of a sound and paste it into a new matrix.
I now want it to allow me to paste another section that will join onto the end of the sound already in the matrix. When I try and do this I get the error:
Warning: Integer operands are required for colon operator when used as index.
> In WaveEditor>sndedit_paste_Callback at 315
In gui_mainfcn at 75
In WaveEditor at 44
Warning: Integer operands are required for colon operator when used as index.
> In WaveEditor>sndedit_paste_Callback at 315
In gui_mainfcn at 75
In WaveEditor at 44
??? Error using ==> plot
Vectors must be the same lengths.
Code:
function snd_copy_Callback(hObject, eventdata, handles)
snd_section = [handles.snd(handles.snd_startposx:handles.snd_endposx)];
handles.snd_section = snd_section
set(handles.snd_pos, 'String', 'Section Copied');
guidata(hObject, handles);
Copies a section of the sound matrix into a new one. For example, the new matrix will be "snd_section: [1x31457 double]".
function sndedit_paste_Callback(hObject, eventdata, handles)
if (handles.sndedit_toggle == 0)
sndedit = handles.snd_section;
axes(handles.sndedit_axes);
hold on
pl = plot(sndedit);
set(pl, 'HitTest', 'off')
handles.sndedit = sndedit
handles.sndedit_toggle = 1
else
sndedit_temp = handles.sndedit;
handles.sndedit = [sndedit_temp(1:sndedit_temp) ,handles.snd_section(1:handles.snd_section)];
axes(handles.sndedit_axes);
CLA
hold on
pl = plot(handles.sndedit);
set(pl, 'HitTest', 'off')
end
guidata(hObject, handles);
Upon first paste, sound is pasted into new matrix and plotted. Upon next paste it will try and join the "snd_section" to the end of "sndedit" and then plot again. The lines where the errors occur are the bold ones.
I've tried this by just creating sound matrixes in the workspace and doing snd3 = [snd1(1:104411) ,snd2(1:264544)]which works but won't when I try and implement it here. I know is somthing to do with the end values but can't see why it won't work.
I now want it to allow me to paste another section that will join onto the end of the sound already in the matrix. When I try and do this I get the error:
Warning: Integer operands are required for colon operator when used as index.
> In WaveEditor>sndedit_paste_Callback at 315
In gui_mainfcn at 75
In WaveEditor at 44
Warning: Integer operands are required for colon operator when used as index.
> In WaveEditor>sndedit_paste_Callback at 315
In gui_mainfcn at 75
In WaveEditor at 44
??? Error using ==> plot
Vectors must be the same lengths.
Code:
function snd_copy_Callback(hObject, eventdata, handles)
snd_section = [handles.snd(handles.snd_startposx:handles.snd_endposx)];
handles.snd_section = snd_section
set(handles.snd_pos, 'String', 'Section Copied');
guidata(hObject, handles);
Copies a section of the sound matrix into a new one. For example, the new matrix will be "snd_section: [1x31457 double]".
function sndedit_paste_Callback(hObject, eventdata, handles)
if (handles.sndedit_toggle == 0)
sndedit = handles.snd_section;
axes(handles.sndedit_axes);
hold on
pl = plot(sndedit);
set(pl, 'HitTest', 'off')
handles.sndedit = sndedit
handles.sndedit_toggle = 1
else
sndedit_temp = handles.sndedit;
handles.sndedit = [sndedit_temp(1:sndedit_temp) ,handles.snd_section(1:handles.snd_section)];
axes(handles.sndedit_axes);
CLA
hold on
pl = plot(handles.sndedit);
set(pl, 'HitTest', 'off')
end
guidata(hObject, handles);
Upon first paste, sound is pasted into new matrix and plotted. Upon next paste it will try and join the "snd_section" to the end of "sndedit" and then plot again. The lines where the errors occur are the bold ones.
I've tried this by just creating sound matrixes in the workspace and doing snd3 = [snd1(1:104411) ,snd2(1:264544)]which works but won't when I try and implement it here. I know is somthing to do with the end values but can't see why it won't work.