필터 지우기
필터 지우기

how I can code this vector x=[1; 1/2;1/3; ......;1/(n-1)] n=15 ?

조회 수: 14 (최근 30일)
MAK
MAK 2018년 9월 23일
댓글: Arun Singh 2022년 9월 7일
How I can code this vector x=[1; 1/2;1/3; ......;1/(n-1)] n=15 ?
  댓글 수: 6
Stephen23
Stephen23 2018년 9월 24일
편집: Stephen23 2018년 9월 24일
n = 15;
v = zeros(n-1,1);
for k = 1:n-1
v(k) = 1/k;
end
But Bish Erbas's answer is preferred.
Arun Singh
Arun Singh 2022년 9월 7일
for n= 1:50
fprintf("1/"+n+", ")
end
Try this

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

채택된 답변

Bish Erbas
Bish Erbas 2018년 9월 24일
편집: Bish Erbas 2018년 9월 24일
Try:
n = 15;
x = 1./(1:n-1);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by