Page 1 of 1

assign parameters in sequence

Posted: Tue Sep 10, 2019 7:54 am
by Bingo LI
Hello all,
I'm working on assigning a parameter in sequence. In my purpose, the sequence of the parameters is:
i=1
P_1= 13
i=2
P_1= 24
i=3
P_1= 15.

However. the result in my programm is
i=1
P_1= 13
i=2
P_1=1 13
2 24
i=3
P_1=1 13
2 24
3 15.

The code is attached. Could someone help me with this problem? thank you.

Re: assign parameters in sequence

Posted: Tue Sep 10, 2019 8:27 am
by Renger
Hi
You are assigning the value to a vector (P_1(ii)) and not to a scalar P_1=P_rec(ii). So,just replace P_1(ii) in your loop by P_1.
Cheers
Renger

Re: assign parameters in sequence

Posted: Tue Sep 10, 2019 11:37 am
by Bingo LI
Thanks for your answer.
However, a vector (P_1(ii)) is needed as there are other variables in my programm.
The purpose of this programm is that I want to eliminate P_1(1) when ii=2.
Could it be done?

Re: assign parameters in sequence

Posted: Tue Sep 10, 2019 5:11 pm
by Renger
Hi
I assume that after assigning the value to P_1(ii) you have some more code that uses the single-valued P_1(ii). You could do this by setting all the values to zero before you assign the single-value and set them after your additional code once again to zero.

Code: Select all

loop (ii,
   P_1(ii) = 0;
   subi(ii)=yes;
   P_1(ii)=P_rec(ii);
* your other code using the P_1(ii) single value
   display subi,P_1;
   subi(ii)=no;
   P_1(ii) = 0;
);
This gives:

Code: Select all

1
----     27 PARAMETER P_1  
1 13.000
----     27 SET subi  
2
----     27 PARAMETER P_1  
2 24.000
----     27 SET subi  
3
----     27 PARAMETER P_1  
3 15.000
I hope this helps
Renger

Re: assign parameters in sequence

Posted: Wed Sep 11, 2019 5:24 am
by Bingo LI
Hi Renger,
It solves my problem perfectly.
Thank you.
Li