3D voxel data without input

조회 수: 1 (최근 30일)
sia
sia 2013년 5월 31일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by