Function in Matlab
Show older comments
Does anybody can tell me plz, how can we see the variables in the workspace when we are using function word in the Editor?
function [h1 h2 h3 h4] = sfighandles;
Cheers
Accepted Answer
More Answers (1)
Wayne King
on 3 May 2012
I'm not exact sure what you are asking, so perhaps you can clarify.
You can declare a variable to be global
>> global X
>> X = randn(10,1);
Then inside a function
function a = testsum
global X
a = sum(X);
end
Note that X is not defined locally inside of testsum.m. I never feel comfortable personally with global variables and just pass what I need to the function.
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!