How to index in for loop

8 次查看(过去 30 天)
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]

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by