Tuesday, May 27, 2008

Assignment #5


Q# 1 Give octave command forconstructing a 256 X 256 matrix with entries of 0 everywhere except inside a circle with radius 50 where the values are 1
Ans:octave-3.0.0.exe:30> X=zeros(256);
octave-3.0.0.exe:31> for A =1:256;
> for B=1:256;
> if(A-128)^2+(B-128)^2 <=2500;
> X(A,B)=1;
> endif;
> endfor;
> endfor;
octave-3.0.0.exe:32> Y=255*X
octave-3.0.0.exe:33> imshow(Y)

No comments: