如何在Matlab符号方程中产生方波 [英] How to have square wave in Matlab symbolic equation

查看:425
本文介绍了如何在Matlab符号方程中产生方波的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目要求我使用Matlab创建一个内部带有方波的符号方程. 我试图这样写,但无济于事:

My project require me to use Matlab to create a symbolic equation with square wave inside. I tried to write it like this but to no avail:

syms t;
a=square(t);

输入参数必须为'double'.

Input arguments must be 'double'.

我该怎么做才能解决此问题?预先感谢您提供的帮助.

What can i do to solve this problem? Thanks in advance for the helps offered.

推荐答案

以下是使用floorsign函数的几个常规选项:

here are a couple of general options using floor and sign functions:

f=@(A,T,x0,x) A*sign(sin((2*pi*(x-x0))/T));
f=@(A,T,x0,x) A*(-1).^(floor(2*(x-x0)/T));

例如,使用floor函数:

 syms x
 sqr=2*floor(x)-floor(2*x)+1;
 ezplot(sqr, [-2, 2])

这篇关于如何在Matlab符号方程中产生方波的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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