0
|
3014 Views
|
|
0 Total Likes
View groups...
Share
GROUPS:

# Recalling an output or assigning a new variable from another variable

Posted 11 years ago
 Hi I am new to Mathematica and I don't understand how to compute my request;I have learned how to use the Switch function and trying to integrate it into a test project. My aim is to be able to select a parameter from a switch, then use that value of the selected parameter to output several variables; In this case, I am using the temperature (K) of several Suns to output a wavelength (nm) and spectrum output (UV, V, IR) individually.eg.(initialization)SunB = 29000SunC = 10000SunD = 2900(manipulate)N[2900000/Switch[Star, SunB, SunB, SunC, SunC, SunD, SunD]],{{Star, SunB, "Star"}, {SunB -> "Sun B", SunC -> "Sun C", SunD -> "Sun D"}}(example output - SunB selected)100I have tried integrating a Which function into the coding, where it give a spectrum output based on which parameter is selected;eg.Which[Star <=100, "Ultraviolet", Star >100 && Star <1000, "Visible", Star =>1000, "Infrared"]I am aware that using this function as is, calls the value of Star, which is either SunB, SunC or SunD, whichever is selected. I am unable to find a way which it can call the value or whichever 'Star' is selected, similarly used in notebook using a % to recall the value which was last output. I can integrate a Which function with defined parameters such as;eg.Which[Star == SunB, "Ultraviolet", Star == SunC, "Visible", Star == SunD, "Infrared"](example output - SunB selected)100.UltravioletHowever I want to develop the demonstration further which requires being able to output the two different variables, I could see two options; one being able to recall the wavelength to compute its spectrum, the other which can put the wavelength into another variable which I can then use, neither I have had any success with.