backward recurssion in a loop
2 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
David Hill
on 20 Sep 2019
c=zeros(9,20);
c(9,:)=b(9,:)-a(9,:);
for i=8:-1:1
c(i,:)=c(i+1,:)-a(i,:);
end
More Answers (0)
See Also
Categories
Find more on Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!