Azzera filtri
Azzera filtri

Conditional Data Selection/Separation

1 visualizzazione (ultimi 30 giorni)
Hi, I have this question, kindly answer it:
PROBLEM STATEMENT:
1- My function has three variables-F,k and X.
2- I need to evaluate the function, f(F,k,X), 10,000 times to get outputs.
3- The variables F, k and X are random. They combine in many different ways to give the outputs.
4- I am only interested in those values that combine to satisfy this condition : f(F,k,X)<1.267.
5- I need to Matlab to separate these values and the corresponding output, f(F,k,X)<1.267.
I have simulation data for F, k, and X, I have computed the outputs, f(F,k,X), and f(F,k,X)<1.267 as well (each 10,000 times). I saved these 5 columns of data in a file named : 'Simd'
I went like this:
Simd;
F=Simd(:,1);
k=Simd(:,2);
X=Simd(:,3);
f(F,k,X)=F.*k.*X
if (f(F,k,X)<1.267)
M=[F k X f(F,k,X)<1.267];
end
My question is in the last three statements, please how do i get a the vector M containing values of F k and X satisfying f(F,k,X)<1.267 in a single file, that is in tabular form? Please what is the problem with my approach? Cheers.

Risposta accettata

Oleg Komarov
Oleg Komarov il 5 Giu 2012
I suggest to read the Language Fundamentals and specifically Matrices and Arrays > Indexing > Matrix Indexing
idx = Simd(:,4) <1.267;
Simd(idx,1:4)
Thus, you don't need loops of if statements.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by