How to find the indices of a vector from another vector

4 次查看(过去 30 天)
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?

采纳的回答

TTA
TTA 2023-6-21
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

更多回答(1 个)

Shubh Pareek
Shubh Pareek 2023-6-19
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 -

类别

Help CenterFile Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by