필터 지우기
필터 지우기

How to find the indices of a vector from another vector

조회 수: 7 (최근 30일)
TTA
TTA 2023년 6월 16일
답변: TTA 2023년 6월 21일
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에서 AI for Signals and Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by