Hello everyone,
I am trying to get output as 2*4 matrix. You can find my simple code as:
t=2;kr=2;s=[0;0];R=[2 3; 3 4];D=[4 5; 5 6];s1=zeros(kr,t);for i=1:kr for j=1:t s1(i,j)=max(s(i)-R(i,j),0)+D(i,j); s(i)=s1(i,j); end ends2=zeros(kr,t);for i=1:kr for j=1:t s2(i,j)=max(s(i)-R(i,j),0)+D(i,j); s(i)=s2(i,j) end endS=[s1 s2]; % final output
I would like to use a single loop rather than repeating the loop for and to get this final output of S (2*4).. It's okay for only s1 and s2 but I have . Any help is appreciated.
Regards
Best Answer