Function in Matlab

8 vues (au cours des 30 derniers jours)
Farideh Jalali
Farideh Jalali le 3 Mai 2012
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

Réponse acceptée

Walter Roberson
Walter Roberson le 3 Mai 2012
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 commentaire
Farideh Jalali
Farideh Jalali le 7 Mai 2012
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;

Connectez-vous pour commenter.

Plus de réponses (1)

Wayne King
Wayne King le 3 Mai 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.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by