How to create a unique output variable name based on input variable name in function
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2014-10-22
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!