MATLAB Function Reference Previous page   Next Page

Assign value to variable in specified workspace



assignin(ws, 'var', val) assigns the value val to the variable var in the workspace ws. var is created if it doesn't exist. ws can have a value of 'base' or 'caller' to denote the MATLAB base workspace or the workspace of the caller function.

The assignin function is particularly useful for these tasks:


The MATLAB base workspace is the workspace that is seen from the MATLAB command line (when not in the debugger). The caller workspace is the workspace of the function that called the M-file. Note that the base and caller workspaces are equivalent in the context of an M-file that is invoked from the MATLAB command line.


This example creates a dialog box for the image display function, prompting a user for an image name and a colormap name. The assignin function is used to export the user-entered values to the MATLAB workspace variables imfile and cmap.

See Also


Previous page  asinh atan Next page

© 1994-2005 The MathWorks, Inc.