filter series based on test but how do I know what series passed??

조회 수: 3 (최근 30일)
Hi all, i had some help with this already from Image but one thing is I need to know what variables passed the test, as there will be another one to run afterwards of which all remaining series need to be identified. Here's what I have so far. I would like to know how I can keep track of which variables passed this test (in this case it's x2 & x3); would appreciate any suggestions. Cheers
x1=5; x2=30; x3=40; x4=3; x=[x1,x2,x3,x4] xTL=sum(x,2)
x=[];
pct=.10;
test1 = pct * xTL
%aggregate test if x1 > test1 fprintf('Adding on x1:\n'); x = [x, x1]; end
if x2 > test1 fprintf('Adding on x2:\n'); x = [x, x2]; end
if x3 > test1 fprintf('Adding on x3:\n'); x = [x, x3]; end
if x4 > test1 fprintf('Adding on x4:\n'); x = [x, x4]; end
  댓글 수: 1
Jeff
Jeff 2013년 9월 25일
편집: Jeff 2013년 9월 25일
Let me clarify further, I would like to run these two tests shown below together and then export the series that have passed the condition to excel but would also need to know the variables that were exported. Can someone help in how to export the results and on how to identify which of the original series are exported.
Here's a similar example as above but with some time series and two conditions present.
%% %data and aggregate x1=[10 8 10]'; x2=[30 29 45]'; x3=[40 15 85]'; x4=[3 2 8]'; x=[x1,x2,x3,x4] xTL=sum(x,2) xTL=xTL(1);
%extracting recent values x_1=x1(1); x_2=x2(1); x_3=x3(1); x_4=x4(1);
%% %diff and percent changes xN=[NaN NaN NaN NaN]; x_d=[diff(-x); xN]; x_p=x_d./x;
%extracting recent percent change for test x1_p=x_p(1,1); x2_p=x_p(1,2); x3_p=x_p(1,3); x4_p=x_p(1,4);
%% test to filter data x=[]; pct=.10;
test1 = pct * xTL; test2 = .05;
%conditional test if ((x_1 > test1) & (abs(x1_p) > test2)) fprintf('Adding on x1:\n'); x = [x, x1]; end
if ((x_2 > test1) & (x2_p > test2)) fprintf('Adding on x2:\n'); x = [x, x2]; end
if ((x_3 > test1) & (x3_p > test2)) fprintf('Adding on x3:\n'); x = [x, x3]; end
if ((x_4 > test1) & (x4_p > test2)) fprintf('Adding on x4:\n'); x = [x, x4]; end

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 9월 25일
whichofthem = find([x2, x2, x3, x4] > test1)
  댓글 수: 1
Jeff
Jeff 2013년 9월 25일
this does return the index of the vector but I guess I should add that the results are to be exported to excel. How can I retrieve the series names for the cases that past the conditions for exporting to excel?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Inputs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by