Home > Archive > Matlab > January 2008 > Re: Urgent help needed for multiple values of x.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Urgent help needed for multiple values of x.
|
|
| Peter Bone 2008-01-31, 5:27 am |
| munday63 <s.munday@uea.ac.uk> wrote in message
<17654239.1201775692105.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hi,
>
> the following works for 1 value of x, however i wish to
use an array (for example x = 1:3).
>
> Any ideas?
>
> x=1;
>
> n = 1:nterms;
>
> approx =
sum((((-1).^(n-1)).*(x.^((2*n)-1)))./factorial(2*n-1));
>
> Thanks
[x n] = meshgrid(1:3,1:nterms);
approx = sum((((-1).^(n-1)).*(x.^((2*n)-1)))./factorial(2*n-1));
Peter Bone
| |
| Walter Roberson 2008-01-31, 10:19 am |
| In article <fns9jp$6vk$1@fred.mathworks.com>,
Peter Bone <peterbone@hotmail.com> wrote:
>munday63 <s.munday@uea.ac.uk> wrote in message
><17654239.1201775692105.JavaMail.jakarta@nitrogen.mathforum.org>...
>use an array (for example x = 1:3).
[color=darkred]
>sum((((-1).^(n-1)).*(x.^((2*n)-1)))./factorial(2*n-1));
>[x n] = meshgrid(1:3,1:nterms);
>approx = sum((((-1).^(n-1)).*(x.^((2*n)-1)))./factorial(2*n-1));
The original poster may note that Peter's solution is explicit code
for the method I recommended to the original poster when they
posted their question the first time. If, after reading the
documentation on the routines I recommended, the method had not
been clear enough, the original poster could have requested further
assistance in the original thread, instead of reposting the entire
question unchanged.
--
So you found your solution
What will be your last contribution?
-- Supertramp (Fool's Overture)
|
|
|
|
|