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

1 件のコメント

Z.khan
Z.khan 2019 年 9 月 20 日
Thanks a lot David.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

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