Function problem once again

9 ビュー (過去 30 日間)
Danny C
Danny C 2016 年 9 月 1 日
編集済み: Stephen23 2016 年 9 月 2 日
Consider the following function and its helper function.
% 1 function E = notebook(in1)
% 2 E = helper(in1);
% 3 end
% 4
% 5 function out3 = helper(in)
% 6 out3 = mod(in,2);
% 7 end
The following code is written in the Command Window and runs without error:
% >> E = 5;
% >> F = notebook(E*2);
% Identify the value of the variable E in each of the following Workspaces. % Write DNE if E is not defined in a particular Workspace.
% The value of E in the notebook function Workspace is: J = 0;
Why isn't it 0? And if not, what is the value of E in the notebook function Workspace?
  2 件のコメント
per isakson
per isakson 2016 年 9 月 2 日
編集済み: per isakson 2016 年 9 月 2 日
notebook is a function of Matlab. Overloading of Matlab functions may cause unexpected behavior. Try to avoid that.
Your functions, notebook and helper, behaves according to my expectations. "Why isn't it 0?" &nbsp It is 0. Obviously, I don't understand the question.
Stephen23
Stephen23 2016 年 9 月 2 日
編集済み: Stephen23 2016 年 9 月 2 日
"Why isn't it 0?"
Why do you think that it isn't zero ?
When I run the code shown above, E is definitely zero inside the notebook workspace:
>> E = 5;
>> notebook(E*2)
ans = 0

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by