Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Function with a variable output

1 visualización (últimos 30 días)
Patrick Aoun
Patrick Aoun el 24 de Mayo de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentario
Guillaume
Guillaume el 24 de Mayo de 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.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by