Dynamically accessing the corresponding variables

Shubha
Shubha New Altair Community Member
edited November 5 in Community Q&A
Hi,

I have an exampleset,

A B C D Var_A Var_B Var_C Var_D
23 45 67 89 5 5 5 4
23 45 12 76 6 4 6 3
23 45 67 78 7 3 7 2
87 54 32 23 3 2 8 1

As you see there are four A, B, C, D variables and their corresponding Var_A, Var_B, Var_C, Var_D variables. Now, I need four other columns giving the differences. (say (A-Var_A)...). The result should be:

Diff_A Diff_B Diff_C Diff_D
18 40 62 85
17 41 6 73
16 42 60 76
84 52 24 22

I attach the datafile, data.txt. And the case could be, I will have A, B, C, D, E,F...... variables

[attachment deleted by admin]
Tagged:

Answers

  • TobiasMalbrecht
    TobiasMalbrecht New Altair Community Member
    Hi,

    you could use the [tt]AttributeConstruction[/tt] operator to calculate the differences. You could also combine this operator with a [tt]FeatureIterator[/tt] to automatically iterate over attributes and calculate the differences.

    Kind regards,
    Tobias
  • Shubha
    Shubha New Altair Community Member
    Thanks Tobias,

    I quick question... It seems that i should use two "FeatureIterator" operators (one for A, B, C, D) and the other for 'Var' variables. Am I correct?

    Thanks, Shubha
  • TobiasMalbrecht
    TobiasMalbrecht New Altair Community Member
    Hi Shubha,

    no, just use one [tt]FeatureIterator[/tt] and set the attribute regex accordingly. In the [tt]AttributeConstruction[/tt] use the loop macro and generate the difference expressions using that macro.

    Regards,
    Tobias
  • Shubha
    Shubha New Altair Community Member
    Thank you very much... It worked...