hi, i want to generation an matrix that simulate an image of size 198*211*3 so i used this code:
clc
close all
clear all
for i=1:4;
for j=1:4;
x(i,j)=rand*100;
if x(i,j)>=0 && x(i,j)<=255;
x
end
end
end
is this work correct? thank you

댓글 수: 1

Walter Roberson
Walter Roberson 2018년 3월 19일
Code that includes "clear all" is almost never correct.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2018년 3월 19일

0 개 추천

x = randi([0 255], 198, 211, 3, 'uint8');

댓글 수: 1

mohammed abdul wadood
mohammed abdul wadood 2018년 3월 19일
in facet i used this solution like this:
x=randi([0 255],198,211)
but I thought it's wrong; but now you Improve it in your solution, thank you sir, thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by