Using a variable (slider) as variable name?

Tedus shared this question 6 years ago
Answered

Hi, if I have the following defined:


z_1=1+i

z_2=-1+i

n=1 (Slider from 1 to 2 increment by 1)


How can I define:


z_3=z_n

So that if the slider = 1 then z_3=z_1 and if slider = 2 then z_3=z_2

Best Answer
photo

There are more ways to do that. Here are two:

A) Define z_3 as follows:

  1. If(n ≟ 1, z_1, z_2)

where you can enter the boolean equality symbol typing "=="


B) In the properties of the slider n - Scripting - On Update insert the code:

  1. Execute({"z_3=z_"+n})

Comments (1)

photo
2

There are more ways to do that. Here are two:

A) Define z_3 as follows:

  1. If(n ≟ 1, z_1, z_2)

where you can enter the boolean equality symbol typing "=="


B) In the properties of the slider n - Scripting - On Update insert the code:

  1. Execute({"z_3=z_"+n})

© 2023 International GeoGebra Institute