Create vector/matrix inside function
Mostrar comentarios más antiguos
Hi All,
I have a simple function file.
If I put something like this inside the function file; A = [1 2 3 4];
It will display this in the command window;
A = 1 2 3 4
But it won't save A in the Workspace as a vector.
How can I create a vector inside a function file and have that vector saved to my Workspace?
Thanks!

Respuesta aceptada
Más respuestas (1)
Stefan Raab
el 9 de Mayo de 2016
Hello,
this is because functions have their own workspace. There is a good explanation in the MATLAB doc, please execute the following commands in the MATLAB Command Window to open the help browser:
- Information on workspaces in general:
web(fullfile(docroot, 'matlab/matlab_prog/base-and-function-workspaces.html'))
- Information on how to share data between workspaces:
web(fullfile(docroot, 'matlab/matlab_prog/share-data-between-workspaces.html'))
I hope this will help you.
Kind regards, Stefan
2 comentarios
Tejay Lovelock
el 9 de Mayo de 2016
Stefan Raab
el 9 de Mayo de 2016
Ah, I was too slow :)
Categorías
Más información sobre Historical Contests en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!