How to create a vector with a sequence 1, u, u(u-1), u(u-1)(u-2)....

How to create a vector with a sequence 1, u, u(u-1), u(u-1)(u-2)....

5 comentarios

Rik
Rik el 7 de Sept. de 2018
What have you tried so far, and what do you mean by u, can you give an example?
What is the mathematics behind 1 being present at the beginning of the sequence? The rest is easy to state mathematically in terms of the pochhammer symbol, but the 1 does not appear to fit.
Ok. Give the code for rest of the sequence. I will try to fit 1 into the victor.
PJS KUMAR
PJS KUMAR el 7 de Sept. de 2018
Editada: PJS KUMAR el 7 de Sept. de 2018
I tried as
A(1)=1;
For i=2:n
A(i)=A(i-1)*(u-(i-2))
Does u(u-1) indicate indexing u at index u-1 or does it indicate multiplying the scalar u by (the scalar u minus 1)?

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Sept. de 2018
Editada: Walter Roberson el 7 de Sept. de 2018
syms u
n = 7;
A = [1,cumprod(u - (0:n))];
A =
[ 1, u, u*(u - 1), u*(u - 1)*(u - 2), u*(u - 1)*(u - 2)*(u - 3), u*(u - 1)*(u - 2)*(u - 3)*(u - 4), u*(u - 1)*(u - 2)*(u - 3)*(u - 4)*(u - 5), u*(u - 1)*(u - 2)*(u - 3)*(u - 4)*(u - 5)*(u - 6), u*(u - 1)*(u - 2)*(u - 3)*(u - 4)*(u - 5)*(u - 6)*(u - 7)]

Más respuestas (1)

u=input('Enter the value of u (more than 1): ');
n=input('Enter the numbers of Elements required: ');
a(1)=1;
for i=2:n
a(i)=a(i-1)*(u-i+2);
end
disp(a);

2 comentarios

Thank you for your response. But I want the vector in terms of 'u' only, without taking value for 'u'.
Rik
Rik el 7 de Sept. de 2018
At some point you'll have to enter a value for u. Or do you plan on using the symbolic toolbox for further analysis?

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 7 de Sept. de 2018

Editada:

el 7 de Sept. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by