Definition function with variable in name

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
Vrbic
Messages
400
Reaction score
18
Hello,
I would like to create few functions in loop by Table (not ordinary change a parameter, but different numerical solution of problem). The names should differ by "number"of the step, let's say "i", in the name. I.e. I would like to get set of function f"i"={f1=Interpolation[data], f2=Interpolation[data1],...}
Can you advise me how to write the definition of function with variable "i" in name?

Thank you for a help.
 
Physics news on Phys.org
Dale said:
Just use f[1]=Interpolation[data1] etc.
Thank you, very clever solution :-)
And just hypothetically, if I would like to specify a variable of the function. I tried f[x_]=..., but it doesn't work.
 
Vrbic said:
Thank you, very clever solution :-)
And just hypothetically, if I would like to specify a variable of the function. I tried f[x_]=..., but it doesn't work.
You would need to use delayed set for that
Code:
 f[i][x_]:= ...

But I wouldn't recommend that. I would use immediate set on the function name only
 
Last edited:
Dale said:
You would need to use delayed set for that
Code:
 f[i][x_]:= ...

But I wouldn't recommend that. I would use immediate set on the function name only
Haaa it works :-)
Thank you very much.