Removing element from two vectors by using ginput

1 view (last 30 days)
Hello, i am using ginput to manually remove a peak from my plot. I have the locations of my peaks and their amplitudes in handles.R_t and handles.R_amp respectively. The following doesnt seem to work and returns empty row and columns as the maximum that I find around the neighbourhood of the click is slightly different from the value I have stored in the handles.R_t. Any help/solution or any clever ideas to avoid this problem?
[x_peak1,y_peak,button] = ginput(1);
[yy xx] = max(handles.bpf((round(x_peak1*handles.srate))-50:(round(x_peak1*handles.srate))+40));
y_peak = yy;
x_peak = xx/handles.srate + x_peak1 - 50/handles.srate;
temp1 = handles.R_t;
temp2 = handles.R_amp';
handles.R_t = zeros(1,length(temp1)-1);
handles.R_amp = zeros(1,length(temp2)-1);
viBelow = (temp1<x_peak);
viAbove = (temp1>x_peak);
newa = [temp1(viBelow) temp1(viAbove)]';
[row,column] = find(temp1 == x_peak);
Anew = zeros(1,length(temp2)-1);
Anew = temp2([1:row-1, row+1:end]);
handles.R_t = newa';
handles.R_amp = Anew;

Answers (0)

Community Treasure Hunt

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

Start Hunting!