Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Function with a variable output

2 visualizzazioni (ultimi 30 giorni)
Patrick Aoun
Patrick Aoun il 24 Mag 2016
Chiuso: MATLAB Answer Bot il 20 Ago 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 Commento
Guillaume
Guillaume il 24 Mag 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.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by