Okay, so I managed to get it to work, *slightly*. I decided to concatencate cell array B entirely (made by bwboundaries), thus removing the nested for loop (shown below):
for k = 1:length(B) %for every cell in B...
boundary = B{k};
z = repmat(i*(0.25/resolution),(height(boundary)),1); %z coordinates is an array of repeated numbers that is iterated by 1 every loop
...the size of the array changes depending on the size of the chosen cell array of B
fill3(boundary(:,1), boundary(:,2), z, 'c', 'EdgeColor', [0 0.4470 0.7410], 'EdgeAlpha', 0.15, 'LineWidth', 0.25/resolution)
...%fill3 generates 3D plots and also fills in enclosed geometry with color
end
replacing it instead with:
boundary = cell2mat(B);
boundary(:,3) = (0.25*i);
fill3(boundary(:,1), boundary(:,2), boundary(:,3), 'c', 'EdgeColor', [0 0.4470 0.7410], 'EdgeAlpha', 0.15, 'LineWidth', 0.25/resolution)
...%fill3 generates 3D plots and also fills in enclosed geometry with color
Unfortunately, this has caused another issue:
It appears that concatencating all of the points into a single 2d matrix means that boundaries are being connected with a single line, shown below:
Is there a way to remove these unwanted lines that are disrupting the fill3 tool? Adding NaN inbetween boundaries results in the fill3 tool not filling the region, due to the NaN values in the 2d matrix.
Any help would be greatly appreciated!