I have a an array
a=[4 9 7]
A Matrix
b= [5 7;4 2];
I want to have
c1=4*b c2=9*b; c3=7*b
. I want to use c1,c2"c3' later as d1=r-c1*x; d2=r-c2*x; Where r=[4;9]; x=[3 5]

 Accepted Answer

David Hill
David Hill on 2 Apr 2021
Edited: David Hill on 2 Apr 2021
for k=1:length(a)
c(:,:,k)=a(k)*b;%index instead of having different variables
d(:,:,k)=r-c(:,:,k)*x;
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!