필터 지우기
필터 지우기

How to set global options?

조회 수: 2 (최근 30일)
Somebody
Somebody 2013년 1월 20일
Hello.
Im trying to set global options so I can no longer set them in my code, like this:
global options
options = optimset('Display','off');
But when i call:
function
...body...
y = fsolve(......, options)
end
matlab asks me to provide options fisrt. Like he doesnt see it. What do I do wrong? Thank you.

채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 1월 20일
For a global variable to enter the scope of any given workspace you will have to call global var_name again. This will tell MATLAB to make that global variable accessible in that workspace. In you specific case try something like this:
global options
options = optimset('Display','off');
function
...body...
global options
y = fsolve(......, options)
end
But I will still recommend that you pass options as an argument to that function and not use the global approach.
  댓글 수: 2
Somebody
Somebody 2013년 1월 20일
편집: Somebody 2013년 1월 20일
Thank you, it worked. I thought it could speed up my calculations, but it didnt. 1 more question. To speed up (i need to use fsolve like thousants times in a row) i need to set as few options as possible. But printing results (with display 'on' as default) makes it impossible. Is there any other ways to shut the display down? It could be something like 'disp off' maybe.
Shashank Prasanna
Shashank Prasanna 2013년 1월 20일
optimset('Display','off')
is the right way to turn off display. Why are you unable to use this in your program? setting the same options won't necessarily show down your program. You may verify this by using the MATLAB profiler.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by