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