When defining a menu, when you want to get outputs out of one case, in order to use them as inputs in another case, how can you save them in the workspace with a specific name?
Simple: call that function with that variable name as its output argument:
var_name = A(X,Y);
will definevar_name in the workspace where the function is being called. Passing arguments is the fastest, simplest and neatest way of passing variables between workspaces, and this is what MATLAB themselves recommend (see link below). Whatever you do, donot learn sloppy buggy programing by passing arguments usingassignin or globals. Although beginners love using them, actually both of these methods make code slower and buggier.
The entire concept of functions is very similar toencapsulation, which is broken when you start passing variables willy-nilly in and out of their workspaces. It is a bad idea.
Best Answer