如何使用Matlab制作零和一的对角线分频器? [英] How to make a diagonal divider of zeros and ones using Matlab?

查看:19
本文介绍了如何使用Matlab制作零和一的对角线分频器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我想要的结果.位数分辨率为256 x 256.

This is the result that I want. The number of bits resolution are 256 x 256.

// assign default background to white.
img = ones(256, 256);

示例结果:

0 1 1 1
0 0 1 1
0 0 0 1
0 0 0 0

有没有办法可以在 MATLAB 中使用 zeros()ones() 函数来实现这个结果?我应该如何进行循环?

Is there a way that I can use the zeros() and ones() function in MATLAB to achieve this result? How should I do the looping?

结果是 eye() 函数可以做的事情,但它只能做对角线.我想要一条分隔零和一的对角线.

The result is something that eye() function can do, but it only do a diagonal lines. I want a diagonal lines that separate zeros and ones.

推荐答案

您正在寻找 triu 函数

You are looking for the triu function

img = triu( ones( 256 ), 1 );

这篇关于如何使用Matlab制作零和一的对角线分频器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆