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:
help save debugging time

Subject: help save debugging time

From: Yuri Geshelin

Date: 19 Sep, 2008 20:32:02

Message: 1 of 7

Hi,

I am debugging a function, which reads a big data file in the beginning. I do not want to debug this part - it's just a 'load' command, and it is very time-consuming. I want this command to get executed at the first call to the function, and to be skipped during the subsequent calls - so that the function will remember the read variable(s) during the rest of debugging process. How can I do it?

Thanks,

Yuri

Subject: help save debugging time

From: Jeremy Greenwald

Date: 19 Sep, 2008 20:56:50

Message: 2 of 7

Have you looked into making the variable that is used to save the data
persistent, so it only have to be read once? Are subsequent loads reading
in the exact same data?
"Yuri Geshelin" <geshelin@hotmail.com> wrote in message
news:gb1282$epe$1@fred.mathworks.com...
> Hi,
>
> I am debugging a function, which reads a big data file in the beginning. I
> do not want to debug this part - it's just a 'load' command, and it is
> very time-consuming. I want this command to get executed at the first call
> to the function, and to be skipped during the subsequent calls - so that
> the function will remember the read variable(s) during the rest of
> debugging process. How can I do it?
>
> Thanks,
>
> Yuri
>

Subject: help save debugging time

From: Yuri Geshelin

Date: 21 Sep, 2008 03:13:06

Message: 3 of 7

Hi Jeremy,

Thanks for your reply. Yes, the subsequent loads are reading the same data, and yes, I tried the use of 'persistent'. Problem is, it works unless you save the m file - obviously, this is what you do in the debugging process. Once you have made any change and save your file, the value stored in a persistent variable is lost.

I guess matlab developers had a good reason for doing it this way, but I found 'persistent' not helpful in my case.

Any other suggestions?

Yuri

"Jeremy Greenwald" <jgreenwa@mathworks.com> wrote in message <gb13mi$qs7$1@fred.mathworks.com>...
> Have you looked into making the variable that is used to save the data
> persistent, so it only have to be read once? Are subsequent loads reading
> in the exact same data?
> "Yuri Geshelin" <geshelin@hotmail.com> wrote in message
> news:gb1282$epe$1@fred.mathworks.com...
> > Hi,
> >
> > I am debugging a function, which reads a big data file in the beginning. I
> > do not want to debug this part - it's just a 'load' command, and it is
> > very time-consuming. I want this command to get executed at the first call
> > to the function, and to be skipped during the subsequent calls - so that
> > the function will remember the read variable(s) during the rest of
> > debugging process. How can I do it?
> >
> > Thanks,
> >
> > Yuri
> >
>

Subject: help save debugging time

From: Walter Roberson

Date: 21 Sep, 2008 08:43:25

Message: 4 of 7

Yuri Geshelin wrote:
> Yes, the subsequent loads are reading the same data, and
> yes, I tried the use of 'persistent'. Problem is, it works unless you save
> the m file - obviously, this is what you do in the debugging process. Once you
> have made any change and save your file, the value stored in a persistent
> variable is lost.

> I guess matlab developers had a good reason for doing it this way, but I
> found 'persistent' not helpful in my case.

Then use "global" instead of "persistent" until you finish your debugging.

Subject: help save debugging time

From: Yuri Geshelin

Date: 21 Sep, 2008 14:25:04

Message: 5 of 7

Walter Roberson <roberson@hushmail.com> wrote in message <kOnBk.11463$Il.10205@newsfe09.iad>...
> Yuri Geshelin wrote:
> > Yes, the subsequent loads are reading the same data, and
> > yes, I tried the use of 'persistent'. Problem is, it works unless you save
> > the m file - obviously, this is what you do in the debugging process. Once you
> > have made any change and save your file, the value stored in a persistent
> > variable is lost.
>
> > I guess matlab developers had a good reason for doing it this way, but I
> > found 'persistent' not helpful in my case.
>
> Then use "global" instead of "persistent" until you finish your debugging.

Thanks Walter,

Looks like a natural solution. Let us now wait for suggestions from "antiglobalists", who maintain that virtually every use of global can and must be avoided.

Yuri

Subject: help save debugging time

From: Jeremy Greenwald

Date: 22 Sep, 2008 16:33:23

Message: 6 of 7

Not to disappoint, but there is a way to continue to use persistent variable
without resort to globals. Have a single function that persists the data
you are interested in, while the function you are developping has a call to
that function. Now the function that has the persistent variable won't need
to be re-saved and therefore won't need to reload the data.

function iAmBeingDebugged

data = justTheData;
...
end

function data = justTheData
persistent d;
...
data = d;
end

"Yuri Geshelin" <geshelin@hotmail.com> wrote in message
news:gb5lg0$91o$1@fred.mathworks.com...
> Walter Roberson <roberson@hushmail.com> wrote in message
> <kOnBk.11463$Il.10205@newsfe09.iad>...
>> Yuri Geshelin wrote:
>> > Yes, the subsequent loads are reading the same data, and
>> > yes, I tried the use of 'persistent'. Problem is, it works unless you
>> > save
>> > the m file - obviously, this is what you do in the debugging process.
>> > Once you
>> > have made any change and save your file, the value stored in a
>> > persistent
>> > variable is lost.
>>
>> > I guess matlab developers had a good reason for doing it this way, but
>> > I
>> > found 'persistent' not helpful in my case.
>>
>> Then use "global" instead of "persistent" until you finish your
>> debugging.
>
> Thanks Walter,
>
> Looks like a natural solution. Let us now wait for suggestions from
> "antiglobalists", who maintain that virtually every use of global can and
> must be avoided.
>
> Yuri
>

Subject: help save debugging time

From: Yuri Geshelin

Date: 22 Sep, 2008 18:50:18

Message: 7 of 7

Thanks Jeremy,

Thanks a lot, no disappointment, on the contrary. I tried hard to desprove my belief about "global" (including calls to other functions), but could not come up with your solution... It now makes perfect sense.

Yuri

"Jeremy Greenwald" <jgreenwa@mathworks.com> wrote in message <gb8hcl$ak4$1@fred.mathworks.com>...
> Not to disappoint, but there is a way to continue to use persistent variable
> without resort to globals. Have a single function that persists the data
> you are interested in, while the function you are developping has a call to
> that function. Now the function that has the persistent variable won't need
> to be re-saved and therefore won't need to reload the data.
>
> function iAmBeingDebugged
>
> data = justTheData;
> ...
> end
>
> function data = justTheData
> persistent d;
> ...
> data = d;
> end
>
> "Yuri Geshelin" <geshelin@hotmail.com> wrote in message
> news:gb5lg0$91o$1@fred.mathworks.com...
> > Walter Roberson <roberson@hushmail.com> wrote in message
> > <kOnBk.11463$Il.10205@newsfe09.iad>...
> >> Yuri Geshelin wrote:
> >> > Yes, the subsequent loads are reading the same data, and
> >> > yes, I tried the use of 'persistent'. Problem is, it works unless you
> >> > save
> >> > the m file - obviously, this is what you do in the debugging process.
> >> > Once you
> >> > have made any change and save your file, the value stored in a
> >> > persistent
> >> > variable is lost.
> >>
> >> > I guess matlab developers had a good reason for doing it this way, but
> >> > I
> >> > found 'persistent' not helpful in my case.
> >>
> >> Then use "global" instead of "persistent" until you finish your
> >> debugging.
> >
> > Thanks Walter,
> >
> > Looks like a natural solution. Let us now wait for suggestions from
> > "antiglobalists", who maintain that virtually every use of global can and
> > must be avoided.
> >
> > Yuri
> >
>

Tags for 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