Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Function with a variable output

1 view (last 30 days)
Patrick Aoun
Patrick Aoun on 24 May 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
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 Comment
Guillaume
Guillaume on 24 May 2016
"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.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!