How to create a unique output variable name based on input variable name in function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hithere
le 22 Oct 2014
Réponse apportée : Star Strider
le 22 Oct 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 commentaires
Réponse acceptée
Star Strider
le 22 Oct 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!