is the window below in the picture the "base workspace"?
and if yes what is the variables that could be stored in it?
Capture.png

답변 (1개)

Walter Roberson
Walter Roberson 2020년 2월 8일

0 개 추천

In context it probably is the base workspace. Any variable can be stored there. Any time you are not executing inside any function then any assignment goes into the base workspace by default, and you can use assignin('base') to deliberately assign into it.

댓글 수: 5

Osama Alkurdi
Osama Alkurdi 2020년 2월 8일
when you say in context, did you mean in matlab documentation?
and when I assign variables in function script, it goes to that workspace in the picture above (which is the base workspace as you said)
that's complicated !!!
Walter Roberson
Walter Roberson 2020년 2월 8일
when you say in context, did you mean in matlab documentation?
No, I mean that I look at your image and I do not see anything entered into the left side window (the command window) so it appears that you are not in the middle of a function execution.
If you were in the middle of a function execution then the Workspace window could still show up empty like that, in the case where the function had no parameters and you had not assigned anything to any variables yet, but in that situation it would be more likely that I would be able to see a hint of what you were doing in the left side window.
But as far as what you showed to us is concerned, it is possible that there is something just out of view to the left, so it is possible that you are not looking at the base workspace and are instead looking at the workspae of a function.
and when I assign variables in function script, it goes to that workspace in the picture above
not if you called the script inside a function. Not even if the first script called a second script. No matter how many levels of scripts you have that call each other, any assignment made from a script called from a function goes into the workspace of the function, rather than into the base workspace. Variables only get assigned by default into the base workspace in the case there is no function running.
Steven Lord
Steven Lord 2020년 2월 8일
You might find the explanation on this documentation page useful to understand the difference between the base workspace and function workspaces.
Osama Alkurdi
Osama Alkurdi 2020년 2월 9일
@Steven Lord
thank you, that's help me very much
Osama Alkurdi
Osama Alkurdi 2020년 2월 9일
@Walter Roberson
OK, I finally get it
But, I have one more question
if the variables in nested function can be used by the parent function (if the nested function has been executed first of course)
and if the variables in parent function can be used by the nested function (if the variables defined before calling that nested function of course)
so, what is the use from global defined variables?

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

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

릴리스

R2018a

태그

질문:

2020년 2월 8일

댓글:

2020년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by