Effacer les filtres
Effacer les filtres

How to find the indices of a vector from another vector

7 vues (au cours des 30 derniers jours)
TTA
TTA le 16 Juin 2023
Réponse apportée : TTA le 21 Juin 2023
I have two sets of array A and B in the attachment.
Dataset A is the cone of influence (COI) of the power of wavelet B. Which means they both have the same length. When I plot it looks like the graph below.
Please how can I find the position of A (COI) in the matrix B (contour) or how can I select the variables inside the COI?

Réponse acceptée

TTA
TTA le 21 Juin 2023
This was the answer I expect.
power = (abs(wave)).^2 ; % compute wavelet power spectrum
incoi=(period(:)*(1./coi)<1);
Powd1 = zeros(numel(power(:, 1)), numel(power(1, :)));
for k = 1:numel(power(1, :))
for j = 1:numel(power(:, 1))
pow1 = power(j, k);
incoi1 = incoi(j, k);
if incoi1 == 1
Powd1(j,k) = pow1;
else
Powd1(j,k) = nan;
end
end
end

Plus de réponses (1)

Shubh Pareek
Shubh Pareek le 19 Juin 2023
Hi @TTA,
From what I have understood you want points from B which follow a certain condition with respect to points in A.
You can try this method -
%So suppose if your array A is
A = [ 5 4 3 2 1 2 3 4 5 ]
A = 1×9
5 4 3 2 1 2 3 4 5
%and B is
B = [ 10 8 6 4 2 4 6 8 10 ; 4 3 2 1 0 1 2 3 4 ]
B = 2×9
10 8 6 4 2 4 6 8 10 4 3 2 1 0 1 2 3 4
%and time axis is
time = [1 2 3 4 5 6 7 8 9]
time = 1×9
1 2 3 4 5 6 7 8 9
%now you plot your respective values
plot(time,A)
hold on
plot(time,B)
xlabel("time")
%let the middle line be our COI, and you only want points in between then
%we create new array B_inside which only has points from B which are inside
%A
hold off
inside_points = B-A > 0 %this will chose indices from B which follow this condition
inside_points = 2×9 logical array
1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
B_inside = B.*inside_points %and then we make the indices that we don't want as 0
B_inside = 2×9
10 8 6 4 2 4 6 8 10 0 0 0 0 0 0 0 0 0
plot(time,A)
xlabel("time")
hold on
plot(time,B_inside)
%now we have points that are only inside the middle curve
I hope this helps with your quey .
Helpfull Resources -

Catégories

En savoir plus sur AI for Signals and Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by