How to create a vector with a sequence 1, u, u(u-1), u(u-1)(u-2)....
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
PJS KUMAR
le 7 Sep 2018
Modifié(e) : Walter Roberson
le 7 Sep 2018
How to create a vector with a sequence 1, u, u(u-1), u(u-1)(u-2)....
5 commentaires
Walter Roberson
le 7 Sep 2018
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)?
Réponse acceptée
Walter Roberson
le 7 Sep 2018
Modifié(e) : Walter Roberson
le 7 Sep 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)]
0 commentaires
Plus de réponses (1)
KALYAN ACHARJYA
le 7 Sep 2018
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 commentaires
Rik
le 7 Sep 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?
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!