Function inside a function

Hello, I'm having some problem with a function defined in terms of other functions: specificly I'm trying to parse a regular expresion with a CFG. The problem is that one of the functions, don't start where it should.
Is something like this:
function [D cad2]=Prod(cad1)
[D cad2]=Termin(cad1)
if ~isempty(cad2)
while strcmp(cad2(1),'.')
[E cad2]=Termin(cad2);
After I execute Termin, I want that the "function Prod" start in [E cad2]=Termin(cad2); not from the beginning.
Thanks.

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 4 月 21 日

0 投票

You cannot change where a function starts.
Perhaps you want to use "persistent", if you want to save state between calls to "Prod".
Daniel Shub
Daniel Shub 2012 年 4 月 22 日

0 投票

You could just recursively call the function Prod.

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2012 年 4 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by