Function in Matlab

12 次查看(过去 30 天)
Farideh Jalali
Farideh Jalali 2012-5-3
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

采纳的回答

Walter Roberson
Walter Roberson 2012-5-3
You cannot. Variables in the workspace are dynamic, created at execution time, but when you are in the editor you are working statically.
The closest you could get would be to have function input parameter names pop-up as you are typing a reference to a function. In the above example, sfighandles has no input parameters, so nothing useful could be done for it.
  1 个评论
Farideh Jalali
Farideh Jalali 2012-5-7
I write the following codes,But still I have problem.
[h1,h2,h3,h4]=sfighandles;
function [h1 h2 h3 h4] = sfighandles;
%--------------------------------------------------------------------------
% Define small figure handles for drawing 4 graphs on screen:-
scrsz = get(0,'ScreenSize'); % tells us the screen size
% Use command: figure('Position', [left, bottom, width, height])
h1 = figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2.4]);
h2 = figure('Position',[scrsz(3)/2 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2.4]);
h3 = figure('Position',[1 4 scrsz(3)/2 scrsz(4)/2.4]);
h4 = figure('Position',[scrsz(3)/2 4 scrsz(3)/2 scrsz(4)/2.4]);
return;

请先登录,再进行评论。

更多回答(1 个)

Wayne King
Wayne King 2012-5-3
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.

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by