0
点赞
收藏
分享

微信扫一扫

MATLAB用矩阵创建大型矩阵以及创建RGB图像


首先创建矩阵:

查阅资料,只有三种创建矩阵的方法。

1,使用a=[1,2;]

MATLAB用矩阵创建大型矩阵以及创建RGB图像_调用函数

2,使用.m文件【就是调用函数】:

3,使用函数:ones()_zeros():

ones(6):生成6*6里面数值为1的矩阵:

MATLAB用矩阵创建大型矩阵以及创建RGB图像_调用函数_02

 

zeros(6):生成6*6里面数值为0的矩阵:

MATLAB用矩阵创建大型矩阵以及创建RGB图像_调用函数_03

创建好矩阵之后:

创建的是300*300的:

MATLAB用矩阵创建大型矩阵以及创建RGB图像_调用函数_04

代码:

clc,clear,close all;

r=zeros(300);
r(1:100,:)=1;
subplot(331),imshow(r);title('r');

g=zeros(300);
g(100:199,:)=1;
subplot(332),imshow(g);title('g');

b=zeros(300);
b(200:299,:)=1;
subplot(333),imshow(b);title('b');

subplot(334),imshow(cat(3,r,g,b));title('rgb');
subplot(335),imshow(cat(3,r,b,g));title('rbg');
subplot(336),imshow(cat(3,g,r,b));title('grb');
subplot(337),imshow(cat(3,g,b,r));title('gbr');
subplot(338),imshow(cat(3,b,g,r));title('brg');
subplot(339),imshow(cat(3,b,r,g));title('brg');

结果:

MATLAB用矩阵创建大型矩阵以及创建RGB图像_调用函数_05

举报

相关推荐

0 条评论