How can I create array of numbers +5 the previous number?

조회 수: 8 (최근 30일)
Collegue
Collegue 2020년 2월 21일
답변: Sindar 2020년 2월 21일
I want to create an array like this
1 5 10 15 etc.
I want to create an array doing +5 the previous number
How can I do it?
  댓글 수: 1
Stephen23
Stephen23 2020년 2월 21일
편집: Stephen23 2020년 2월 21일
"I want to create an array doing +5 the previous number"
1+5 = 5 ???
How do you add five to one ... and get five ?
"How can I do it?"
I guess you will either have to redefine addition, or redefine the natural numbers.

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

답변 (1개)

Sindar
Sindar 2020년 2월 21일
start_num = 1;
end_num = 15;
x=[start_num:5:end_num];
% note that 15 is not included since 1+5+5+5=16
If you actually want the example you gave:
end_num = 15;
x = [1 5:5:end_num];

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by