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

조회 수: 1 (최근 30일)
PJS KUMAR
PJS KUMAR 2018년 9월 7일
편집: Walter Roberson 2018년 9월 7일
How to create a vector with a sequence 1, u, u(u-1), u(u-1)(u-2)....
  댓글 수: 5
PJS KUMAR
PJS KUMAR 2018년 9월 7일
편집: PJS KUMAR 2018년 9월 7일
I tried as
A(1)=1;
For i=2:n
A(i)=A(i-1)*(u-(i-2))
Walter Roberson
Walter Roberson 2018년 9월 7일
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)?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 7일
편집: Walter Roberson 2018년 9월 7일
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)]

추가 답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 7일
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
PJS KUMAR
PJS KUMAR 2018년 9월 7일
Thank you for your response. But I want the vector in terms of 'u' only, without taking value for 'u'.
Rik
Rik 2018년 9월 7일
At some point you'll have to enter a value for u. Or do you plan on using the symbolic toolbox for further analysis?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by