question about going out from internal function to main script

1 回表示 (過去 30 日間)
ahmed
ahmed 2013 年 9 月 14 日
Hello Everybody ;
I have 3 functions intertwined like that
x= function1(y)
.
.
w=function2(z)
.
.
e=function3(m)
.
.
end
end
end
so my question is , i want to go out from function3(or the main script) to function1 without passing through function2, i know that (return) make me go out from function3 to function2 but this is not what i want.
so any help here
  1 件のコメント
Jan
Jan 2013 年 9 月 14 日
編集済み: Jan 2013 年 9 月 14 日
Do you mean:
function x = function1(y)
...
function w = function2(z)
etc
? In the original code, there are not "3 functions", but only 1.

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

回答 (2 件)

Chetan Rawal
Chetan Rawal 2013 年 9 月 14 日
I would rather create sub-functions and call them the way you want. The nested function structure you have right now may make it hard for the kind of flow you want. This link may help you.

Image Analyst
Image Analyst 2013 年 9 月 14 日
Just get rid of the "end"s and list them all in a single file one after the other. The way you have it now, they're nested which you say you don't want. Or if you really want to keep the "end"s you can, just don't put the functions inside each other, list them one at a time, one after the other, like
function function1()
% code
end
function function2()
% code
end
function function3()
% code
end

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by