Conditional Data Selection/Separation

조회 수: 8 (최근 30일)
Usman
Usman 2012년 6월 5일
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.

채택된 답변

Oleg Komarov
Oleg Komarov 2012년 6월 5일
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개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by