Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Adding the arrays number

조회 수: 1 (최근 30일)
Offroad Jeep
Offroad Jeep 2015년 10월 3일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi to all, I have generated random numbers
a = 0
da = rand(1,10)
now i want to add a+da so that the previous result add to next rand no. for example
a = 0
da = 1 2 3 4
a_new = 0+1 = 1
in the next step
a_new = 1+2 =3
in the next step
a_new = 3+3 = 6
in the next step
a_new = 6+4 =10
etc

답변 (1개)

Walter Roberson
Walter Roberson 2015년 10월 3일
t = [a da];
t(1:end-1) + t(2:end)
  댓글 수: 2
Offroad Jeep
Offroad Jeep 2015년 10월 3일
편집: Offroad Jeep 2015년 10월 3일
kindly see the question ..... your answer is not working......... kindly check it thanks...........
Walter Roberson
Walter Roberson 2015년 10월 3일
a_new = cumsum(da);

Community Treasure Hunt

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

Start Hunting!

Translated by