I have a 64X64 matrix that is just filled with 1\'s or 0\'s. Iused the image com
ID: 1829305 • Letter: I
Question
I have a 64X64 matrix that is just filled with 1's or 0's. Iused the image command to put it into plot form. I usedcolormap(gray) to attempt to make the 0's black and the 1's white.It is not working since the whole picture is still black. When ibring the numbers to 256 and 0 it is black and white. It doesn'tmake sense because from what I read it sounds like colormap(gray)should make zero and one be the limits.What am Imisunderstanding.Below is code that it should be working in.
function [o]=circle(r)
%-----------fills the matrix
clc
close all
o=zeros(64,64);
for y=1:65
for x=1:65
a=abs(32-y);
b=abs(32-x);
c=sqrt(a^2+b^2);
if c<=r
o(y,x)=1;
end
end
end
%-------------plots the matrix
colormap(gray)
image(o)
axis square
grid on
hold on
plot (32,32,'o')
Like i said it comes up all black and i want the zeros to be blackand ones to white. So a white circle with black background. Anyhelp would be greatly appreciated.
Explanation / Answer
figure;imshow(o);
these commands should follow directly after u havecompleted building the matrix..
Check if it works. imshow(o);
these commands should follow directly after u havecompleted building the matrix..
Check if it works.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.