Removing element from two vectors by using ginput
2 ビュー (過去 30 日間)
古いコメントを表示
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;
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!