| MATLAB Function Reference | Search  Help Desk |
| assignin | Examples See Also |
Assign value to variable in workspace
assignin(ws,'name',v)
assignin(ws,'name',v)
assigns the variable 'name' in the workspace ws the value v. 'name' is created if it doesn't exist. ws can be either 'caller' or 'base'.
Here's a function that creates a variable with a user-chosen name in the base workspace. The variable is assigned the value
.
function sqpi
var = inputdlg('Enter variable name','Assignin Example',1,{'A'})
assignin('base','var',sqrt(pi))
evalin Evaluate expression in workspace.