Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Depth problem

Subject: Depth problem

From: Jane

Date: 10 Jun, 2007 06:18:36

Message: 1 of 7

Hi, Does anyone know how can I solve the following problem?
I need to use eval function to valuate a string with a parenthesis
nesting more than 32 depth.
when I using eval(string) I got the following message:

   message: 'Error: Nesting of {, [, and ( cannot exceed a depth of
32.'
    identifier: 'MATLAB:m_parenthesis_depth'
         stack: [0x1 struct]

It works in matlab 6.5 and 7.1 but not in matlab 2007a.

Subject: Depth problem

From: Joseph

Date: 10 Jun, 2007 14:13:25

Message: 2 of 7

Is there any reason you're using so many nesting functions? I mean
other than to make MatLab cry? Is there anyway you can break your
string of functions up?

 Jane wrote:
>
>
> Hi, Does anyone know how can I solve the following problem?
> I need to use eval function to valuate a string with a parenthesis
> nesting more than 32 depth.
> when I using eval(string) I got the following message:
>
> message: 'Error: Nesting of {, [, and ( cannot exceed a depth of
> 32.'
> identifier: 'MATLAB:m_parenthesis_depth'
> stack: [0x1 struct]
>
> It works in matlab 6.5 and 7.1 but not in matlab 2007a.

Subject: Depth problem

From: Jane

Date: 11 Jun, 2007 03:32:20

Message: 3 of 7

Thank Joseph,
I do not want to make matlab cry and I just want to use it. I can
break the string manually but the purpose I use it is to pick up
hundreds of long string formulas and to evaluate which one is better.
If Matlab want to keep the group of evolution computation it has to
change.
Matlab 2007a should be imporved than 7.1 but not worse.
Any one has some suggestion ??
Jane

Joseph wrote:
>
>
> Is there any reason you're using so many nesting functions? I mean
> other than to make MatLab cry? Is there anyway you can break your
> string of functions up?
>
> Jane wrote:
>>
>>
>> Hi, Does anyone know how can I solve the following problem?
>> I need to use eval function to valuate a string with a
> parenthesis
>> nesting more than 32 depth.
>> when I using eval(string) I got the following message:
>>
>> message: 'Error: Nesting of {, [, and ( cannot exceed a depth
of
>> 32.'
>> identifier: 'MATLAB:m_parenthesis_depth'
>> stack: [0x1 struct]
>>
>> It works in matlab 6.5 and 7.1 but not in matlab 2007a.

Subject: Depth problem

From: Jonathan Currie

Date: 22 Apr, 2012 01:46:24

Message: 4 of 7

Did you ever manage to solve this problem? I have just encountered the same in R2011b... Real pain!

Jane <MATLAB.TOOL@YAHOO.IE> wrote in message <ef59e31.1@webcrossing.raydaftYaTP>...
> Thank Joseph,
> I do not want to make matlab cry and I just want to use it. I can
> break the string manually but the purpose I use it is to pick up
> hundreds of long string formulas and to evaluate which one is better.
> If Matlab want to keep the group of evolution computation it has to
> change.
> Matlab 2007a should be imporved than 7.1 but not worse.
> Any one has some suggestion ??
> Jane
>
> Joseph wrote:
> >
> >
> > Is there any reason you're using so many nesting functions? I mean
> > other than to make MatLab cry? Is there anyway you can break your
> > string of functions up?
> >
> > Jane wrote:
> >>
> >>
> >> Hi, Does anyone know how can I solve the following problem?
> >> I need to use eval function to valuate a string with a
> > parenthesis
> >> nesting more than 32 depth.
> >> when I using eval(string) I got the following message:
> >>
> >> message: 'Error: Nesting of {, [, and ( cannot exceed a depth
> of
> >> 32.'
> >> identifier: 'MATLAB:m_parenthesis_depth'
> >> stack: [0x1 struct]
> >>
> >> It works in matlab 6.5 and 7.1 but not in matlab 2007a.

Subject: Depth problem

From: ImageAnalyst

Date: 22 Apr, 2012 03:29:17

Message: 5 of 7

On Apr 21, 9:46 pm, "Jonathan Currie" <jonathan.cur...@hotmail.com>
wrote:
> Did you ever manage to solve this problem? I have just encountered the same in R2011b... Real pain!
---------------------------------------------------
The solution was to create intermediate variables from an interior
set. Count the number of left parentheses in the string. If it's
more than 32, start finding matching pairs of parentheses and making
them their own variable. It might be inconvenient but what other
option do you have?

Subject: Depth problem

From: Claudio

Date: 18 Apr, 2014 17:53:09

Message: 6 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <86ba94ec-36e3-4747-92b7-1f3312daacbc@i18g2000vbx.googlegroups.com>...
> On Apr 21, 9:46 pm, "Jonathan Currie" <jonathan.cur...@hotmail.com>
> wrote:
> > Did you ever manage to solve this problem? I have just encountered the same in R2011b... Real pain!
> ---------------------------------------------------
> The solution was to create intermediate variables from an interior
> set. Count the number of left parentheses in the string. If it's
> more than 32, start finding matching pairs of parentheses and making
> them their own variable. It might be inconvenient but what other
> option do you have?

In 2014 this daft error is still there, we need to write a script to find a workaround...

Subject: Depth problem

From: Steven Lord

Date: 18 Apr, 2014 22:23:40

Message: 7 of 7


"Claudio " <claudioangione@libero.it> wrote in message
news:liroq4$59t$1@newscl01ah.mathworks.com...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message
> <86ba94ec-36e3-4747-92b7-1f3312daacbc@i18g2000vbx.googlegroups.com>...
>> On Apr 21, 9:46 pm, "Jonathan Currie" <jonathan.cur...@hotmail.com>
>> wrote:
>> > Did you ever manage to solve this problem? I have just encountered the
>> > same in R2011b... Real pain!
>> ---------------------------------------------------
>> The solution was to create intermediate variables from an interior
>> set. Count the number of left parentheses in the string. If it's
>> more than 32, start finding matching pairs of parentheses and making
>> them their own variable. It might be inconvenient but what other
>> option do you have?
>
> In 2014 this daft error is still there, we need to write a script to find
> a workaround...

WHY do you have a string with more than 32 nested sets of parentheses in it?
Are you trying to do this just to test the limits of MATLAB or do you have
an actual use case where you need to do this?

If the latter, such a string is likely to be EXTREMELY long, and
nigh-unreadable (and unmodifiable -- just figuring out which right
parenthesis matches which left parenthesis is likely to be difficult!) So I
can only assume you have some program that's autogenerating this string. In
that case, I suggest that writing a script (or having the program write a
script file) is not a "workaround" but is the more robust and maintainable
solution. It may also be a better performing solution, if the script file
can define certain quantities (that are used often) as variables that are
then reused where necessary rather than recalculated each time they're used.

For example, if you're converting a symbolic expression (from Symbolic Math
Toolbox) into a string using something like char(symbolicExpression),
consider using matlabFunction instead. It can directly generate a function
file for you from a symbolic expression.

http://www.mathworks.com/help/symbolic/matlabfunction.html

If matlabFunction sees that the expression uses (x+y) in a number of places,
for instance, I think it may be able to define "temp1 = x+y;" and then use
temp1 where appropriate instead of performing the addition each time.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us