Azzera filtri
Azzera filtri

Function in Matlab

3 visualizzazioni (ultimi 30 giorni)
Farideh Jalali
Farideh Jalali il 3 Mag 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

Risposta accettata

Walter Roberson
Walter Roberson il 3 Mag 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 Commento
Farideh Jalali
Farideh Jalali il 7 Mag 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;

Accedi per commentare.

Più risposte (1)

Wayne King
Wayne King il 3 Mag 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.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by