Hi,
I was wondering how to get my code shorter and cleaner as I am basically using the same formula.
A = zeros(1,t);B = zeros(1,t);C = zeros(1,t);D = zeros(1,t);E = zeros(1,t);for z = 1:1:t if z == 1 A(:,z) = v1; B(:,z) = v2; C(:,z) = v3; D(:,z) = v4; E(:,z) = v5; else A(:,z) = A(:,z-1)*(1+rf); B(:,z) = B(:,z-1)*(1+rf); C(:,z) = C(:,z-1)*(1+rf); D(:,z) = D(:,z-1)*(1+rf); E(:,z) = E(:,z-1)*(1+rf); endend
However, I am aware of better not to use eval.
But I do not get it working using an cell array like here with names = {'A' 'B' 'C' 'D' 'E'}. vx are just some values, which I coul also loop from an array.
Thanks in advance!
Best Answer