I'm not really sure that code does what you think it does... you're looping over the points too many times in your drawT function (I don't think you want that outer loop, just a single i to use if your if cases. Also, %k isn't a valid sprintf format, so you're labels are all the same.
Anyway, here's a simplified version... you can build from there.
MON = [2.8 3.6 17.2; 5.4 8.3 15.8; 2.5 3.2 17.6];
Z1={{rand(1,3)},[{rand(1,3)} {rand(1,3)} {rand(1,3)} {rand(1,3)} {rand(1,3)} {rand(1,3)} {rand(1,3)}],[{rand(1,3)} {rand(1,3)} ] }
cl='grbckmyw';
axes('position', [0.1 0.1 0.7 0.8]);
view(3);
hold on;
for ii = 1:size(MON,1)
h1(ii) = plot3(MON(ii,1), MON(ii,2), MON(ii,3), ...
'marker', 'X', ...
'color', cl(ii), ...
'displayname', sprintf('Tazisko %d', ii), ...
'MarkerSize', 10, ...
'linestyle', 'none');
end
cl='gbrcmykw';
for ii = 1:size(Z1,2)
xyz = cat(1, Z1{ii}{:});
h2(ii) = plot3(xyz(:,1), xyz(:,2), xyz(:,3), ...
'marker', 's', ...
'color', cl(ii), ...
'displayname', sprintf('Zhluk %d', ii), ...
'markersize', 10, ...
'linestyle', 'none');
end
leg1 = legendflex(h1, get(h1, 'DisplayName'), 'anchor', {'ne','nw'}, 'buffer', [5 0]);
leg2 = legendflex(h2, get(h2, 'DisplayName'), 'anchor', {'se','sw'}, 'buffer', [5 0]);
Best Answer