Filter löschen
Filter löschen

Function in Matlab

3 Ansichten (letzte 30 Tage)
Farideh Jalali
Farideh Jalali am 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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 Kommentar
Farideh Jalali
Farideh Jalali am 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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Wayne King
Wayne King am 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.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by