Covert a cell with the same indices into individual matrices
Ältere Kommentare anzeigen
Hello, does anyone how I can convert a 10*10 cell array that each contains a 4*4 matrix into individual matrices. For example considering the code below:
x1 = rand(10,10);
y1 = rand(10,10);
z1 = rand(10,10);
r1 = rand(10,10);
a1 = cat(3,x1,y1,z1,r1);
x2 = rand(10,10);
y2 = rand(10,10);
z2 = rand(10,10);
r2 = rand(10,10);
a2 = cat(4,x2,y2,z2,r2);
tmp = num2cell(sqrt(a1./a2),3:4);
fun = @(a)reshape(a,4,4);
out = cellfun(fun,tmp,'uni',0);
What I'm looking to do is to convert each components of the cell with the same index into a seperate matrix, so that at the end I would have 16 seperate 10*10 matrices. For example considering all the (1,1) of the cells (out{1}(1,1), out{2}(1,1), out{3}(1,1), ...). Can one for loop be used to this conversion that at the end 16 different 10*10 matrices will be produced? Or is it better to change the method to calculate the result of the above code (out) from the beginning so that the matrices are obtained themselves? Thank you.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Descriptive Statistics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!