Private workspace for assigning variables and evaluating expressions
docmaker.Workspace has no public properties.
w = docmaker.Workspace() creates a new, empty workspace w.
w = docmaker.Workspace(n1,v1,n2,v2,...) creates a workspace w, and assigns variable n1 to value v1, variable n2 to value v2, etc.
| Name | Description | Type | Required |
|---|---|---|---|
n➡️ |
variable name(s) | string(s) | |
v➡️ |
variable value(s) | any | |
➡️w |
workspace | docmaker.Workspace |
assignin(w,n,v) assigns the variable n to value v in the workspace w.
assignin(w,n1,v1,n2,v2,...) assigns variable n1 to value v1, variable n2 to value v2, etc. in the workspace w.
| Name | Description | Type | Required |
|---|---|---|---|
w➡️ |
workspace | docmaker.Workspace |
yes |
n➡️ |
variable name(s) | string(s) | |
v➡️ |
variable value(s) | any |
evalin(w,s) evaluates the statement(s) s in the workspace w.
[o1,o2,...] = evalin(w,s) evaluates the statement s in the workspace w, and returns the outputs o1, o2, etc. It is not possible to return outputs from multiple statements or assignments.
c = evalinc(w,s) evaluates the statement(s) s in the workspace w, and returns the command window output c.
[c,o1,o2,...] = evalinc(w,s) evaluates the statement s in the workspace w, and returns the outputs o1, o2, etc. and the command window output c.
| Name | Description | Type | Required |
|---|---|---|---|
w➡️ |
workspace | docmaker.Workspace |
yes |
s➡️ |
statement(s) | string | yes |
➡️c |
command window output | string | |
➡️o |
output(s) | any |
clearvars(w,n1,n2,...) clears the variables n1, n2, etc. from the workspace w.
clearvars(w) clears all variables from the workspace w.
| Name | Description | Type | Required |
|---|---|---|---|
w➡️ |
workspace | docmaker.Workspace |
yes |
n➡️ |
variable name(s) | string(s) |
save(w,f) saves all variables in the workspace w to the file f.
save(w,f,n1,n2,...) saves the variables n1, n2, etc. in the workspace w to the file f.
load(w,f) loads all variables from the file f into the workspace w.
load(w,f,n1,n2,...) loads the variables n1, n2, etc. from the file f into the workspace w.
| Name | Description | Type | Required |
|---|---|---|---|
w➡️ |
workspace | docmaker.Workspace |
yes |
f➡️ |
filename | string | yes |
n➡️ |
variable name(s) | string(s) |
Create a workspace, assign some variables, and evaluate an expression:
w = docmaker.Workspace("a",2,"b",3);
evalin(w,"c=a+b;")
wEvaluate an expression without capturing the output:
evalin(w,"d=a*b+c")Here, the variable d is in w, and is shown in the output because the statement d=a*b+c is not terminated.
Evaluate an expression in the workspace and assign the result to a variable:
x = evalin(w,"a*b+c")Here, the variable x is not in w, it is in the caller workspace.
You can also capture the output using evalinc, and return it to the caller.
evalinc(w,"e=a+b*c")Create a workspace, and assign some variables:
w1 = docmaker.Workspace("a",-1,"b","mickey")Save the workspace contents to a .mat file:
f = tempname() + ".mat";
save(w1,f)Create a second workspace, and assign some variables:
w2 = docmaker.Workspace("b",2,"c","pluto")Load the contents of the first workspace into the second:
load(w2,f)
w2docmaker.Workspace extends assignin and evalin from base and caller to workspace objects. docmaker.Workspace also adds evalinc -- "evalin with capture". evalin is to evalinc as eval is to evalc.
docmaker.Workspace was previously a standalone implementation, first implemented 20 years ago, but now uses matlab.lang.internal.WorkspaceData ❤️.
home 🏠 | convert ➡️ | run 🏃 | index 📜 | delete ♻️ | workspace 👷 | about 🐣 | ©️ MathWorks 2024-2026