필터 지우기
필터 지우기

Function in Matlab

조회 수: 3 (최근 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에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by