Obtaining a list of (x, y) points that correspond to specific values of concentration that are chosen at random

2 visualizzazioni (ultimi 30 giorni)
Hello,
I need to generate a matrix of points given that they meet the condition that at these (x,y) points concentration is greater than 10. Note that I first run a code that gives me concentration at each location c(x,y,t), and now from the results of the first run I need Matlab to "randomly" pick (x,y) points with the above condition. Also, note the dimensions of the results from the first Matlab run (which the random sampling should be based on): concentration changes with location and time and is 52x61x61, x is 1x61, y is 1x52, and time is 1x61.
I have previously asked this question, and got an answer that allows me to generate a random sample of concentrations that meet the condition, but I don't know how to make the association of these concentrations with the x,y, and t that correspond to these values as per the original Matlab results. For example, for a randomly chosen concentration with a value of 50, what is x and y at which this value is observed?
Would appreciate any suggestions on how to go about this.

Risposta accettata

Thomas Koelen
Thomas Koelen il 20 Mag 2015
Modificato: Thomas Koelen il 20 Mag 2015
clc
clear all
close all
NOP=10;
A=rand(52,61,61)*100;
B=0;
Z=0;
while length(B)<NOP
X=randi([1 52]);
Y=randi([1 61]);
T=randi([1 61]);
if A(X,Y,T)>10
Z=Z+1;
B(Z,1)=A(X,Y,T);
B(Z,2)=X;
B(Z,3)=Y;
B(Z,4)=T;
end
end
This should somewhat do what you want. (If I understand you correctly)
NOP is the number of points you want and A is the array that contains your data.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by