my issue is that i need to have the output date of the for loop to be saved under a unique variable title (eg. pipearray1) for when M=1. and then (pipearray2) when M=2. I then need to be able to multiply all the outcomes (which will vary depending on the value of M which is defined by the input array (that a user will put in)) to leave me with a final 2x2 matrix.
f & M are defined in a script file earlier.
function [ finalmatrix ] = for2( array, f, M )
for length = 1:M
k = (2*pi*f) / array(M,4);
Y = array(M,4) / array(M,2);
const = k*array(M,1);
A = cos(const);
D = cos(const);
B = i * Y * sin (const);
C = (i/Y) * sin (const);
pipearray = [A B;C D];
finalmatrix = %a multiplication of all the unique variables of pipearray.
i have tried to use this function directly below 'pipearray = [A B;C D];' line, it returns with a varying variable name but it doesnt seem to save them all as variables in the workspace, is there anything wrong with this? and if this can be made to work how do you then multiply all the results?
v = genvarname('pipearray', who);
val([v ' = [A B;C D]'])