this may sound awkward, i tried a loop but i am getting error(attempt to access), what i am trying to do is subtracting 2 arrays
A=[0;10;20;30;40]
V(1,1)=100 it starts with one value then changes its dimension to obtain V(2,1)=V(1)-A(1) and V(3,1)=V(2)-A(1) and the result will be
V= [100;90;70;40;0]
i also tried `cumsum` , but may be i didn't use it right !

댓글 수: 2

Walter Roberson
Walter Roberson 2016년 1월 12일
Does A(2) ever get used in the calculation?
sami elahj
sami elahj 2016년 1월 12일
편집: sami elahj 2016년 1월 12일
yeah it does thats why V(2)=100-10=90, its like storing the value the V(1) then use it to get V(2)

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

답변 (1개)

the cyclist
the cyclist 2016년 1월 12일

0 개 추천

A = [0;10;20;30;40]
V = 100 - cumsum(A);

카테고리

도움말 센터File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

질문:

2016년 1월 12일

편집:

2016년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by