Conditional Data Selection/Separation
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Oleg Komarov
le 5 Juin 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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!