matlab制造一个64*64的仿真数据

时间:2023-03-08 16:41:50
fid = fopen('test_001.img','w');
r=random('Normal',100,0,64,64);
z=random('Uniform',0,5,64,64); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=14;
b=16;
for i=15:18
for j=a:b
r(i,j)=random('Normal',102,0,1,1);
end
a = a-1;
b = b+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=15:18
for j=31:34
r(i,j)=random('Normal',102,0,1,1);
end
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=14:19
for j=47:48
r(i,j)=random('Normal',102,0,1,1);
end
end for i=16:17
for j=45:50
r(i,j)=random('Normal',102,0,1,1);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% a=13;
b=17;
for i=30:35
for j=a:b
r(i,j)=random('Normal',102,0,1,1);
end a=a-1;
b=b+1; end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=30:35
for j=30:35
r(i,j)=random('Normal',102,0,1,1);
end
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i =29:35
for j=47:49
r(i,j)=random('Normal',102,0,1,1);
end
end for i=31:33
for j=45:51
r(i,j)=random('Normal',102,0,1,1);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% a=13;
b=18;
for i=46:53
for j=a:b
r(i,j)=random('Normal',102,0,1,1);
end
a=a-1;
b=b+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=45:53
for j=29:37
r(i,j)=random('Normal',102,0,1,1);
end
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=44:53
for j=46:49
r(i,j)=random('Normal',102,0,1,1);
end
end for i=47:50
for j=43:52
r(i,j)=random('Normal',102,0,1,1);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r=r+z;count =fwrite(fid,r);
fclose('all');

fid = fopen('test_002.img','w');
s=random('Normal',100,0,64,64);z=random('Uniform',0,5,64,64);
for i=8:12
for j=8:12
s(i,j)=random('Normal',102,0,1,1);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s=s+z;count=fwrite(fid,s);
fclose('all');