Hi!
I would be grateful if anyone could help me with something similar to the following problem.
if
I have a matrix A=rand(n,a)
where n=9 and a=20
I have B=rand(1, 20)
I need to solve for C (n, a) which has to be solved backwards using A and B. The last row of C can be obtained by subtracting the last row of A from B. So, C(9,:)=B-A(9,:).
C(n-1,:) can be recovered by backward recurrsion so Now C(8, :)=C(9,:)-A(8,:) similarly C(7,:)=C(8,:)-A(8,:) and so forth and so on up to C(1,:)=C(2:)-A(2,:).
Can someone help with how can this be iterated in a loop?

 채택된 답변

David Hill
David Hill 2019년 9월 20일

0 개 추천

c=zeros(9,20);
c(9,:)=b(9,:)-a(9,:);
for i=8:-1:1
c(i,:)=c(i+1,:)-a(i,:);
end

추가 답변 (0개)

카테고리

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

질문:

2019년 9월 20일

댓글:

2019년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by