Code covered by the BSD License  

Highlights from
RGB Cube

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 1.45 KB File ID: #31233

RGB Cube

by Esteban m.

 

28 Apr 2011

3D cube whith shades of red, green and blue

| Watch this File

File Information
Description

x=[
     NaN 0 1 NaN % NaN= not a number
       0 0 1 1
       0 0 1 1
     NaN 0 1 NaN
     NaN 0 1 NaN
     NaN NaN NaN NaN
     ];
y=[
     NaN 0 0 NaN
       0 0 0 0
       1 1 1 1
     NaN 1 1 NaN
     NaN 0 0 NaN
     NaN NaN NaN NaN
     ];
z=[
     NaN 0 0 NaN
       0 1 1 0
       0 1 1 0
     NaN 0 0 NaN
     NaN 0 0 NaN
     NaN NaN NaN NaN
     ];

     cc=zeros(8,3); % zeros crea un arreglo de 8(Colores) por 3(x,y,z)
     cc(1,:)=[0 0 0]; % black
     cc(2,:)=[1 0 0]; % red
     cc(3,:)=[0 1 0]; % green
     cc(4,:)=[0 0 1]; % blue
     cc(5,:)=[1 0 1]; % magenta
     cc(6,:)=[0 1 1]; % cyan
     cc(7,:)=[1 1 0]; % yellow
     cc(8,:)=[1 1 1]; % white
     cs=size(x);
     c=repmat(zeros(cs),[1 1 3]);%repmat crea una nueva matriz donde cada reglon contiene el arreglo zeros
for i=1:size(cc,1)
     ix=find(x==cc(i,1) &...
             y==cc(i,2) &...
             z==cc(i,3));
     [ir,ic]=ind2sub(cs,ix);
for k=1:3
for m=1:length(ir)
     c(ir(m),ic(m),k)=cc(i,k);
end
end
end
     s=surf(x,y,z,c);
     shading interp; % Para que difumine el color
     xlabel('x');
     ylabel('y');
     zlabel('z');
     title('CuboRGB);
     axis equal;
     axis on;
rotate3d on

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
image processing Esteban m. 28 Apr 2011 16:17:44

Contact us at files@mathworks.com