How do I delete a repeated element in a single array cell?
Show older comments
I am trying to applying a filter through an array of signals, but the filter must be aligned with the signal's peak (max value). For this I wrote the following:
desv = 10; %constant for the filter function below
filt = @(x) exp(-(t-t(x)).^2/desv); %filter function depending on t (a time array)
%to select the x for the correct time point, I must find the max of each
%signal
b2 = {};
samn = {};
for x = 1:size(sam_pulse,1) %sam_pulse is the 2295 x 449 data array
[~,b3] = find(sam_pulse(x,:) == max(sam_pulse(x,:))); %find the cell with max value
b2{x} = b3; %store it in the empty cell above
filt_b2 = filt(b2(x)); %use function on the discovered time point
samn(x) = sam_pulse.*filt_b2; %apply the filter on each row of the data array
end
The problem is that some of the signals in the array have more than one cell with the same max value. This means that, for example, b2{17} = 174 and 175.
I must apply the filter to a single point, so I want to ignore the second max value, whilst still keeping it in its array. By this, I mean that I want the max value to be identified on cell 174. And therefore align my filter with said cell 174.
How can I tell the programme to solely store the first number on b2?
Accepted Answer
More Answers (0)
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!