在MatLab中绘制正弦波的倒数 [英] Plotting the reciprocal of a sine wave in MatLab

查看:176
本文介绍了在MatLab中绘制正弦波的倒数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难在MatLab中绘制基本正弦波的倒数.我正在关注的教程(不是MatLab教程)是通过在每个垂直渐近线之间放置几个点来手工绘制的,以使您了解图形的外观.我已经尝试过使用MatLab的csc()函数,并且沿着x侧面绘制的图形与所绘制的示例完全不同.从0pi的绘制示例看起来与大的U相似,而从pi2*pi的示例为负版本(上下颠倒).这是我尝试过的所有不同代码组合:

I'm having difficulties trying to plot the reciprocal of a basic sine wave within MatLab. The tutorial I'm following (not a MatLab tutorial) is plotting it by hand by placing a few points between each vertical asymptote to give you an idea of what the graph will look like. I've tried using MatLab's csc() function, and the graph when plotted along side x is nothing like the drawn example. The drawn example from 0 to pi looks similar to a big U and from pi to 2*pi is a negative version (upside down). Here is all the different combinations of code I've tried:

x = 0:0.01:100;
y = 5*csc(x); % amplitude of -5 to 5
plot(x,y)

然后我尝试:

x = 0:0.01:100;
y = 1 / 5*sin(x);  % amplitude of -5 to 5 
plot(x,y)

两者的结果截然不同.我想知道使用矢量x是否可以,因为在我以前的一篇文章中,我对标准MatLab三角函数设置为采用弧度而非度表示印象?

Both results are dramatically different. I was wondering if using the vector x was okay as I was under the impression after one of my previous posts that the standard MatLab trig functions are setup to take radians rather than degrees?

推荐答案

可以尝试一下-

x = 0 : 0.01 : 2*pi;
y = csc(x);
plot(x,y)
ylim([-10, 10])

这是您期望的吗?

这篇关于在MatLab中绘制正弦波的倒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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