find indices in a large array and replace them with zeros
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Konstantinos
le 17 Août 2016
Commenté : Konstantinos
le 17 Août 2016
I have an index with 10 rows and 301 columns each. I also have a digital signal with 1 X 250,000 elements. The values of the initial index are isolated from the digital signal because they all have a specific characteristic and I used the following code for this:
index1 = zeros(10,151);
index2 = zeros(10,150);
for i = 1:10
index1(i,:) = signal(peak(i):(peak(i)+150));
index2(i,:) = signal((peak(i)-150):(peak(i)-1));
end
index = [index2,index1];
Up to this point everything is fine. However, I want to delete that characteristic by replacing all the index values with zeros back at the digital signal. My problem is that the element arrays in the "index", corresponding to the 10 rows, aren't neighbouring. How can I do this? Would it be easier if I make the replacement within the for loop? Thanks in advance.
Réponse acceptée
Thorsten
le 17 Août 2016
for i = 1:10
index1(i,:) = signal(peak(i):(peak(i)+150));
index2(i,:) = signal((peak(i)-150):(peak(i)-1));
end
Setting the signal to zero at the peak indices:
for i = 1:10
signal((peak(i)-150):(peak(i)+150)) = 0;
end
Note that you cannot do the replacement in the same for loop, since the peak(i)-150):(peak(i)+150) may overlap, an then you pick up zeros instead of the real signal values.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!