In this MWE, I generate dis (x, y, z displacements for nodes and increments), I then need to extract separately the displacements
clear
k=0;
% ignore following, this is just to buils dis
for node=1:20
for incr=1:100
k=k+1;
dis{node,incr}(1)=k; % X coordinate
dis{node,incr}(2)=2*k; % Y coordinate
dis{node,incr}(3)=3*k; % Z coordinate
end
end
I would like to build U, V, W arrays from dis. However, the
following statement fails:
U(:,:)=dis{:,:}(1);
Any concise way to make that substitution?
You can use
Alternatively,
However, consider defining
disdirectly as a 3D array (of size20×100×3in your example), and then everything will be easier. There seems to be no need for a cell array here.