nested function calculation problem

1 view (last 30 days)
Hello everyone,
I'm trying to write a code that consists of an if and a nested function. I try, each nested function works seperately but It doesn't work when you put it together. The general structure is as follows. It enters the nested function and calculates correctly, but does not print the answer. Where is the problem?
Thanks
function abc(a1,b1,c1)
x;
y;
z;
function x
if statement
statement
else statement
statement
end
end
function y
if statement
else statement
end
end
function z
if statement
else statement
end
end
result=x+y+z
end

Accepted Answer

Walter Roberson
Walter Roberson on 29 Nov 2021
Your functions do not return values. You cannot add them.
  4 Comments
Walter Roberson
Walter Roberson on 30 Nov 2021
Shared variables are slower than passing parameters in and returning outputs.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by