Info

此问题已关闭。 请重新打开它进行编辑或回答。

Function with a variable output

1 次查看(过去 30 天)
Patrick Aoun
Patrick Aoun 2016-5-24
关闭: MATLAB Answer Bot 2021-8-20
Greetings,
I'm trying to create a function that imports data according to the input. If I input "A" I want it to import dataset "A" and add it in the workspace, with the name "A".
I tried creating a function with no outputs but that did nothing.
I was also thinking of creating a function whose output is variable. Something like:
switch Request
case "A"
output: A
case "B"
output: B
end
But I don't know what syntax to use there.
This would be simple if I use
output = A
But that would output a variable called "output" which is not what I want
Thanks in advance.
  1 个评论
Guillaume
Guillaume 2016-5-24
"But that would output a variable called "output" which is not what I want". It may not be what you want but, other than the poor name of the variable, it should be what you want.
It is much better to always import into the same variable, so that whatever code you're using to process the data afterward works regardless of its origin.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by