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:
plot vpi numbers

Subject: plot vpi numbers

From: Syed Galib

Date: 27 Aug, 2009 02:30:22

Message: 1 of 8

Hello,

Is there any method to plot some vpi numbers? Please, inform me if anybody knows anything about this.

Thanks.

Regards
Galib

Subject: plot vpi numbers

From: John D'Errico

Date: 27 Aug, 2009 02:56:03

Message: 2 of 8

"Syed Galib" <galib.cse@gmail.com> wrote in message <h74r3t$443$1@fred.mathworks.com>...
> Hello,
>
> Is there any method to plot some vpi numbers? Please, inform me if anybody knows anything about this.
>
> Thanks.
>
> Regards
> Galib

Hmm. plot in what way? I'd never really thought of
plotting them.

Since they will in general be huge, it might be best to
plot the logs anyway. Since I've implemented the log
of a vpi number, which results in a double, this will be
easy. Of course, if the numbers are small enough to
let them be represented as doubles, then double will
suffice to let them be plotted.

Let me know if there is something I've missed here, or
that I can provide. I'll be happy to do so if I can.

And, of course, if you come up with a neat way to do
something, there are now a few others who have
submitted add-ons to the vpi tools to the FEX, and
one person just sent me a tool to add to the toolbox
directly.

John

Subject: plot vpi numbers

From: Nasser Abbasi

Date: 27 Aug, 2009 02:57:50

Message: 3 of 8


"Syed Galib" <galib.cse@gmail.com> wrote in message
news:h74r3t$443$1@fred.mathworks.com...
> Hello,
>
> Is there any method to plot some vpi numbers? Please, inform me if anybody
> knows anything about this.
>
> Thanks.
>
> Regards
> Galib

vpi as in vpa? Variable precision arithmetic?

You can may be convert the numbers to double() then plot the data?

--Nasser

Subject: plot vpi numbers

From: Syed Galib

Date: 27 Aug, 2009 03:09:02

Message: 4 of 8

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h74sk3$96d$1@fred.mathworks.com>...
> "Syed Galib" <galib.cse@gmail.com> wrote in message <h74r3t$443$1@fred.mathworks.com>...
> > Hello,
> >
> > Is there any method to plot some vpi numbers? Please, inform me if anybody knows anything about this.
> >
> > Thanks.
> >
> > Regards
> > Galib
>
> Hmm. plot in what way? I'd never really thought of
> plotting them.
>
> Since they will in general be huge, it might be best to
> plot the logs anyway. Since I've implemented the log
> of a vpi number, which results in a double, this will be
> easy. Of course, if the numbers are small enough to
> let them be represented as doubles, then double will
> suffice to let them be plotted.
>
> Let me know if there is something I've missed here, or
> that I can provide. I'll be happy to do so if I can.
>
> And, of course, if you come up with a neat way to do
> something, there are now a few others who have
> submitted add-ons to the vpi tools to the FEX, and
> one person just sent me a tool to add to the toolbox
> directly.
>
> John

Hi John,

Thanks for your reply. I was just thinking of plotting the numbers. But as you suggested, I'll try with the log first. But I think, it'd be good for me to plot the numbers directly which is, I think, a tough thing to do. If you have anything then please inform me.

Thanks again.

Regards
Galib

Subject: plot vpi numbers

From: John D'Errico

Date: 27 Aug, 2009 03:28:02

Message: 5 of 8

"Syed Galib" <galib.cse@gmail.com> wrote in message <h74tce$rfb$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message <h74sk3$96d$1@fred.mathworks.com>...
> > "Syed Galib" <galib.cse@gmail.com> wrote in message <h74r3t$443$1@fred.mathworks.com>...
> > > Hello,
> > >
> > > Is there any method to plot some vpi numbers? Please, inform me if anybody knows anything about this.
> > >
> > > Thanks.
> > >
> > > Regards
> > > Galib
> >
> > Hmm. plot in what way? I'd never really thought of
> > plotting them.
> >
> > Since they will in general be huge, it might be best to
> > plot the logs anyway. Since I've implemented the log
> > of a vpi number, which results in a double, this will be
> > easy. Of course, if the numbers are small enough to
> > let them be represented as doubles, then double will
> > suffice to let them be plotted.
> >
> > Let me know if there is something I've missed here, or
> > that I can provide. I'll be happy to do so if I can.
> >
> > And, of course, if you come up with a neat way to do
> > something, there are now a few others who have
> > submitted add-ons to the vpi tools to the FEX, and
> > one person just sent me a tool to add to the toolbox
> > directly.
> >
> > John
>
> Hi John,
>
> Thanks for your reply. I was just thinking of plotting the numbers. But as you suggested, I'll try with the log first. But I think, it'd be good for me to plot the numbers directly which is, I think, a tough thing to do. If you have anything then please inform me.
>
> Thanks again.
>
> Regards
> Galib

You can convert them to doubles. This will work for up to
the limit of a double. And since you are plotting them,
the loss of precision is meaningless.

realmax
ans =
     1.79769313486232e+308

X = randint(vpi(10)^300,[10,1]);
double(X)
ans =
     5.88258675757761e+299
     1.11661968748743e+299
     8.34449222147048e+299
     8.98864325038768e+299
     6.57886636160671e+299
     3.11417544460711e+299
     2.17521364980225e+299
     6.12341103728287e+299
       5.828722736619e+299
     8.18930536981494e+299
plot(double(X))

This works. Had I gone past realmax of course, it
must fail since the conversion to double runs out
of room.

I suppose I could overload plot though. Pull out
the exponent, normalize the numbers, then call
then call plot myself with the scaled numbers as
doubles. Then add the exponent as a scale factor
as plot does now. Something to think about for
the next release...

Easier to plot the logs, base 10. ;-)

John

Subject: plot vpi numbers

From: Syed Galib

Date: 27 Aug, 2009 03:34:02

Message: 6 of 8

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h74ug2$4hr$1@fred.mathworks.com>...
> "Syed Galib" <galib.cse@gmail.com> wrote in message <h74tce$rfb$1@fred.mathworks.com>...
> > "John D'Errico" <woodchips@rochester.rr.com> wrote in message <h74sk3$96d$1@fred.mathworks.com>...
> > > "Syed Galib" <galib.cse@gmail.com> wrote in message <h74r3t$443$1@fred.mathworks.com>...
> > > > Hello,
> > > >
> > > > Is there any method to plot some vpi numbers? Please, inform me if anybody knows anything about this.
> > > >
> > > > Thanks.
> > > >
> > > > Regards
> > > > Galib
> > >
> > > Hmm. plot in what way? I'd never really thought of
> > > plotting them.
> > >
> > > Since they will in general be huge, it might be best to
> > > plot the logs anyway. Since I've implemented the log
> > > of a vpi number, which results in a double, this will be
> > > easy. Of course, if the numbers are small enough to
> > > let them be represented as doubles, then double will
> > > suffice to let them be plotted.
> > >
> > > Let me know if there is something I've missed here, or
> > > that I can provide. I'll be happy to do so if I can.
> > >
> > > And, of course, if you come up with a neat way to do
> > > something, there are now a few others who have
> > > submitted add-ons to the vpi tools to the FEX, and
> > > one person just sent me a tool to add to the toolbox
> > > directly.
> > >
> > > John
> >
> > Hi John,
> >
> > Thanks for your reply. I was just thinking of plotting the numbers. But as you suggested, I'll try with the log first. But I think, it'd be good for me to plot the numbers directly which is, I think, a tough thing to do. If you have anything then please inform me.
> >
> > Thanks again.
> >
> > Regards
> > Galib
>
> You can convert them to doubles. This will work for up to
> the limit of a double. And since you are plotting them,
> the loss of precision is meaningless.
>
> realmax
> ans =
> 1.79769313486232e+308
>
> X = randint(vpi(10)^300,[10,1]);
> double(X)
> ans =
> 5.88258675757761e+299
> 1.11661968748743e+299
> 8.34449222147048e+299
> 8.98864325038768e+299
> 6.57886636160671e+299
> 3.11417544460711e+299
> 2.17521364980225e+299
> 6.12341103728287e+299
> 5.828722736619e+299
> 8.18930536981494e+299
> plot(double(X))
>
> This works. Had I gone past realmax of course, it
> must fail since the conversion to double runs out
> of room.
>
> I suppose I could overload plot though. Pull out
> the exponent, normalize the numbers, then call
> then call plot myself with the scaled numbers as
> doubles. Then add the exponent as a scale factor
> as plot does now. Something to think about for
> the next release...
>
> Easier to plot the logs, base 10. ;-)
>
> John

Dear John,

Thanks for your advice. I am trying to do that. If I get into any problem, I'll ask you again.

Thanks again.

Galib

Subject: plot vpi numbers

From: Syed Galib

Date: 27 Aug, 2009 03:50:18

Message: 7 of 8

>
> You can convert them to doubles. This will work for up to
> the limit of a double. And since you are plotting them,
> the loss of precision is meaningless.
>
> realmax
> ans =
> 1.79769313486232e+308
>
> X = randint(vpi(10)^300,[10,1]);
> double(X)
> ans =
> 5.88258675757761e+299
> 1.11661968748743e+299
> 8.34449222147048e+299
> 8.98864325038768e+299
> 6.57886636160671e+299
> 3.11417544460711e+299
> 2.17521364980225e+299
> 6.12341103728287e+299
> 5.828722736619e+299
> 8.18930536981494e+299
> plot(double(X))
>
> This works. Had I gone past realmax of course, it
> must fail since the conversion to double runs out
> of room.
>
> I suppose I could overload plot though. Pull out
> the exponent, normalize the numbers, then call
> then call plot myself with the scaled numbers as
> doubles. Then add the exponent as a scale factor
> as plot does now. Something to think about for
> the next release...
>
> Easier to plot the logs, base 10. ;-)
>
> John

Hi,
I was trying as you showed like:
plot(double(X))
but using double(X) it resulted in "inf". So, nothing is plotted.
Please, help me out.

Thanks.

Galib

Subject: plot vpi numbers

From: John D'Errico

Date: 27 Aug, 2009 10:15:20

Message: 8 of 8

"Syed Galib" <galib.cse@gmail.com> wrote in message <h74vpq$lh6$1@fred.mathworks.com>...

> >
> > Easier to plot the logs, base 10. ;-)
> >
> > John
>
> Hi,
> I was trying as you showed like:
> plot(double(X))
> but using double(X) it resulted in "inf". So, nothing is plotted.
> Please, help me out.

Your numbers are too large to be represented even
approximately as doubles. This means they are
larger than realmax, which is roughly 1e308. So
when double converts the numbers to the form
that double uses, there is an overflow. It is not
representable.

The solution is to use logs. Logs will tell you far
more of interest about these numbers anyway.

John

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