Azzera filtri
Azzera filtri

3D voxel data without input

2 visualizzazioni (ultimi 30 giorni)
sia
sia il 31 Mag 2013
Hi guys, i have this code to create a 3D voxel grid and a cube within. But I wanna change my code such that i wont need to enter the input in the command windows but rather execute the function and the grid will be displayed.
That is the code:
function voxel(i,d,c,alpha);
switch(nargin),
case 0
disp('Too few arguements for voxel');
return;
case 1
l=1; %default length of side of voxel is 1
c='b'; %default color of voxel is blue
case 2,
c='b';
case 3,
alpha=1;
case 4,
%do nothing
otherwise
disp('Too many arguements for voxel');
end;
x=[i(1)+[0 0 0 0 d(1) d(1) d(1) d(1)]; ...
i(2)+[0 0 d(2) d(2) 0 0 d(2) d(2)]; ...
i(3)+[0 d(3) 0 d(3) 0 d(3) 0 d(3)]]';
for n=1:3,
if n==3,
x=sortrows(x,[n,1]);
else
x=sortrows(x,[n n+1]);
end;
temp=x(3,:);
x(3,:)=x(4,:);
x(4,:)=temp;
h=patch(x(1:4,1),x(1:4,2),x(1:4,3),c);
set(h,'FaceAlpha',alpha);
temp=x(7,:);
x(7,:)=x(8,:);
x(8,:)=temp;
h=patch(x(5:8,1),x(5:8,2),x(5:8,3),c);
set(h,'FaceAlpha',alpha);
axis equal
axis([0,10,0,10,0,10])
xlabel('X-Achse')
ylabel('Y-Achse')
zlabel('Z-Achse')
grid on
end;
At this moment i write e.g. voxel([5 5 5],[1 1 1],'b',0.7); in the command windws for the input. How can i change my code ????
THX

Risposte (0)

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by