필터 지우기
필터 지우기

How to add a variable that is not shown in workplace to the workplace?

조회 수: 2 (최근 30일)
reza
reza 2019년 1월 24일
편집: Stephen23 2019년 1월 24일
Sometimes I write some functions but I cant see some of my variables in workplace after I run the code! Why this happens and how can I see them in workplace too?
for example this code doesn't show the "z" or "a" or "temp" or "p" in the workplace:
z = X * all_theta';
a = sigmoid(z);
[temp p] = max(a, [], 2);

답변 (1개)

Stephen23
Stephen23 2019년 1월 24일
편집: Stephen23 2019년 1월 24일
"Sometimes I write some functions but I cant see some of my variables in workplace after I run the code!"
That is the expected behavior: every function has its own independent workspace:
"Why this happens and how can I see them in workplace too?"
By far the simplest way to get variables from a function workspace into the base workspace is to pass them as output arguments, exactly as the MATLAB documentation recommends:
For example:
function y = myfun(x);
y = sqrt(x)+2;
end
And tested:
>> out = myfun(16)
out = 6

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by