Reading a vector in intervals of 40.

조회 수: 2 (최근 30일)
Ricardo Gutierrez
Ricardo Gutierrez 2019년 10월 2일
댓글: Ricardo Gutierrez 2019년 10월 2일
Hi. Good day.
I would like to help me in the following:
I have a vector A
A = [14 8 12 18 8 34 24 14 12 22 2 20 2 10 16 8 10 18];
I want to add 0 to the first vector element A; 0 + 14 = 14
__ to the second element add 40; 40 + 8 = 48
__ to the third element add 80; 80 + 12 = 92
__ to the fourth element add 120; 120 + 18 = 138
__ to the fifth element add 160; 160 + 8 = 168
and so on (40 by 40).
I have tried with " for " cycles and I have not been able to do it.
In the end the searched vector would be:
[14 48 92 138 168 234 264 294 332 422 442 500 522 570 616 648 690]
Thank you

채택된 답변

Walter Roberson
Walter Roberson 2019년 10월 2일
A = [14 8 12 18 8 34 24 14 12 22 2 20 2 10 16 8 10 18];
A + (0:length(A)-1) * 40
A + (0:40:40*(length(A)-1))
  댓글 수: 1
Ricardo Gutierrez
Ricardo Gutierrez 2019년 10월 2일
Excellent !!!!
It worked
Thank you so much.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by