How to create a unique output variable name based on input variable name in function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hithere
el 22 de Oct. de 2014
Respondida: Star Strider
el 22 de Oct. de 2014
I would really like this output variable to carry the name of my input variable.
That way I can harvest a list of variables in the workspace instead of having to manually change the name of the output variable after each function call.
I hope you understand what I would like to achieve.
This is my function:
.

.
=> the output variable name is always wavelengtha
BUT I would like it to be a "unique other" output variable name, preferably wavelengtha_x (depending on my x input) or just X or something like that
0 comentarios
Respuesta aceptada
Star Strider
el 22 de Oct. de 2014
The output variable is whatever you want to call it. You have to call it ‘wavelengtha’ internally in order for the function to return that variable as output, but ‘wavelengtha’ is only local to your ‘test’ function.
You would call the function, for instance with variables ‘x_1’ and ‘y_1’ and you want to call your wavelength ‘lambda_1’, simply call your function with:
lambda_1 = test(x_1,y_1)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!