Question

Question 2 Problem Definition Write a MATLAB script that uses nested loops to create a 100 by 100 element 2D array representi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 2:

CODE :

a = uint8(zeros(100,100)); %UINT8 Convert to unsigned 8-bit integer.
int = floor(linspace(255,0,100)); % generate 100 level form 255 (white) to 0 (black)
for i=1:100
for j=1:100
a(i,j)=int(i); % i choose the row number
end
end
imshow(a) % display image
imwrite(a,'test2.png'); % to write image

Result:

a -uint8(zeros (100, 100)); int for i-l:100 %UINT8 Convert to unsigned 8-bit integer floor (linspace(255, 0,100)); % generate

Image:

Question 3:

CODE :

a = uint8(zeros(100,100)); %UINT8 Convert to unsigned 8-bit integer.
int = floor(linspace(0,255,100)); % generate 100 level form 0 (black) to 255 (white)
for i=1:100
for j=1:100
a(i,j)=int(j); % i choose the row number
end
end
imshow(a) % display image
imwrite(a,'test3.png'); % to write image

Result:

uint8(zeros (100,100)); %UINT8 Convert to unsigned 8-bit integer. a int -floor(Linspace(0,255,100)); % generate 100 level for

Image:

Question 4:

CODE :

a = uint8(zeros(100,100)); %UINT8 Convert to unsigned 8-bit integer.
int = floor(linspace(255,0,100)); % generate 100 level form 255 (white) to 0 (black)
for i=1:100
for j=1:100
a(i,j)=int(j); % i choose the row number
end
end
imshow(a) % display image
imwrite(a,'test4.png'); % to write image

Result:

-unt8(zeros (100, 100)); %UINT8 Convert to unsigned 8-bit Integer. a int for 2- -floor (linspace (255,0,100)); % generate 100

Image:

Add a comment
Know the answer?
Add Answer to:
Question 2 Problem Definition Write a MATLAB script that uses nested loops to create a 100 by 100...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT