Thread Subject: Creating a vector?

Subject: Creating a vector?

From: nordmoon

Date: 16 Oct, 2009 17:08:16

Message: 1 of 7

I am having trouble creating a vector which contains values between 4.0239*10^(18) and 5.4322*10^(26). I would like to use this as a X-value and calculate the y-values, y(x).

How can I create the vector?

I tried with

x = (4.0239*10^(18)):10000:(5.4322*10^(26))
??? Error using ==> colon
Maximum variable size allowed by the program is exceeded.

but I get an error sign for these big numbers.

Can someone help me? I would be very appreciated for any help I can get.

Subject: Creating a vector?

From: James Tursa

Date: 16 Oct, 2009 17:27:05

Message: 2 of 7

nordmoon <arianadax@gmail.com> wrote in message <870949580.70447.1255712926825.JavaMail.root@gallium.mathforum.org>...
> I am having trouble creating a vector which contains values between 4.0239*10^(18) and 5.4322*10^(26). I would like to use this as a X-value and calculate the y-values, y(x).
>
> How can I create the vector?
>
> I tried with
>
> x = (4.0239*10^(18)):10000:(5.4322*10^(26))
> ??? Error using ==> colon
> Maximum variable size allowed by the program is exceeded.
>
> but I get an error sign for these big numbers.
>
> Can someone help me? I would be very appreciated for any help I can get.

Do the math. That's 4.3458e+023 bytes! You need to rethink your problem.

James Tursa

Subject: Creating a vector?

From: Steven Lord

Date: 16 Oct, 2009 17:31:38

Message: 3 of 7


"nordmoon" <arianadax@gmail.com> wrote in message
news:870949580.70447.1255712926825.JavaMail.root@gallium.mathforum.org...
>I am having trouble creating a vector which contains values between
>4.0239*10^(18) and 5.4322*10^(26). I would like to use this as a X-value
>and calculate the y-values, y(x).
>
> How can I create the vector?
>
> I tried with
>
> x = (4.0239*10^(18)):10000:(5.4322*10^(26))
> ??? Error using ==> colon
> Maximum variable size allowed by the program is exceeded.
>
> but I get an error sign for these big numbers.
>
> Can someone help me? I would be very appreciated for any help I can get.

You will not be able to create such a vector; even if you could, it would
take a VERY long time to evaluate your function on the vector. Such a
vector would have approximately:

>> 1+((5.4322e26-4.0239e18)/10000)

ans =

       5.432199959761e+022

5e22 elements. Your machine doesn't have enough memory to store that many
elements; since each one takes up 8 bytes, you're looking at roughly 4e23
bytes or about 3e11 TERABYTES. Operating on 1e5 elements per second, that
would require 5e17 seconds or approximately 1.6e10 years.

Your best option would be to create a more coarsely-grained vector by using
a larger increment than 10000. Alternately, you _could_ wait for computing
hardware to improve to the point where this size of problem would be
feasible ... but you'd have a LONG wait.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Creating a vector?

From: someone

Date: 16 Oct, 2009 17:33:05

Message: 4 of 7

nordmoon <arianadax@gmail.com> wrote in message <870949580.70447.1255712926825.JavaMail.root@gallium.mathforum.org>...
> I am having trouble creating a vector which contains values between 4.0239*10^(18) and 5.4322*10^(26). I would like to use this as a X-value and calculate the y-values, y(x).
>
> How can I create the vector?
>
> I tried with
>
> x = (4.0239*10^(18)):10000:(5.4322*10^(26))
> ??? Error using ==> colon
> Maximum variable size allowed by the program is exceeded.
>
> but I get an error sign for these big numbers.
>
> Can someone help me? I would be very appreciated for any help I can get.

% How many values (length of x) do you want to create?
% As an alternative, look into using linspace or logspace instead.

x = 10^18*(4.0239:10000:5.4322*10^8);

% or
x = 10^18*linspace(4.0239,5.4322*10^8,10000);
x = 10^18*logspace(4.0239,5.4322*10^8,10000);

% (I get no errors with either of the above.)

Subject: Creating a vector?

From: nordmoon

Date: 16 Oct, 2009 17:43:09

Message: 5 of 7

I don't need the step of 10000, I just need a few points, say 20 or so between that range. Is that possible?

I am doing a simulation of the number density, so 1000 is not needed as step between interval.

Curious, your example gave me inf values in the vector. but thank you for trying. :)

Subject: Creating a vector?

From: someone

Date: 16 Oct, 2009 18:14:03

Message: 6 of 7

nordmoon <arianadax@gmail.com> wrote in message <704434348.70635.1255715020379.JavaMail.root@gallium.mathforum.org>...
> I don't need the step of 10000, I just need a few points, say 20 or so between that range. Is that possible?
>
> I am doing a simulation of the number density, so 1000 is not needed as step between interval.
>
> Curious, your example gave me inf values in the vector. but thank you for trying. :)

% Did you even look at linspace or logspace as I suggested?

doc linspace
doc logspace

% They show you how to do what you want.

Subject: Creating a vector?

From: nordmoon

Date: 16 Oct, 2009 18:27:16

Message: 7 of 7

Yes I just did and it works now. Thanks! :)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
linspace someone 16 Oct, 2009 13:34:10
logspace someone 16 Oct, 2009 13:34:10
rssFeed for this Thread

Contact us at files@mathworks.com