How do write a function within the same main code
13 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I want to know if it is possible to write a function within the same main code rather than write it in separate M file.
Thanks in advance for any help.
0 个评论
采纳的回答
Matt Fig
2011-4-8
Put all of this into one M-file. Then call it like this: get_sub(5)
function [OUT] = get_sub(A)
OUT = subfun(A); % Call the subfunction.
function [OUT_SUB] = subfun(B)
OUT_SUB = B.^2;
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!