Search specific layer of multidimensional matrix for range of values?

2 vues (au cours des 30 derniers jours)
I have a layered matrix (3 layers) seen below and what I want to do is search for a range of values in the 2nd layer and then the 3rd layer and return the indices where the range of numbers are found. Lets say I have a variable dx that has a range of values and I want to return the indices in the 2nd and 3rd layer which have any of these values. Any ideas on how to do this? I was thinking of using the find command but am not sure how to use that with multidimensional matrices. Don't get bogged down by all of the code for setting up the matrices, it is just a simple 180x180 matrix with random integers and 2 layers with specified values in each. Thanks!
dx = -60:1:55
N11 = randi([1,500],45,45);
N12 = randi([25,1000],45,45);
N13 = randi([100,2200],45,45);
N14 = randi([5,700],45,45);
N21 = randi([100,500],45,45);
N22 = randi([800,3500],45,45);
N23 = randi([1000,10000],45,45);
N24 = randi([15,1000],45,45);
N31 = randi([250,900],45,45);
N32 = randi([5000,11000],45,45);
N33 = randi([1750,9000],45,45);
N34 = randi([25,890],45,45);
N41 = randi([2000,7500],45,45);
N42 = randi([200,2300],45,45);
N43 = randi([25,750],45,45);
N44 = randi([50,1323],45,45);
N = [N11 N12 N13 N14;
N21 N22 N23 N24;
N31 N32 N33 N34;
N41 N42 N43 N44];
H1 = -90:1:90;
H2 = H1(find(H1~=0));
V1 = -90:1:90;
V2 = V1';
V3 = V2(find(V2~=0));
N(:,:,2) = H2(ones(180,1),:);
N(:,:,3) = V3(:,ones(180,1));

Réponse acceptée

Thorsten
Thorsten le 12 Avr 2017
Modifié(e) : Thorsten le 12 Avr 2017
idx2 = ismember(N(:,:,2), dx);
idx3 = ismember(N(:,:,3), dx);

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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