Plotting the reciprocal of a sine wave in MatLab

心不动则不痛 提交于 2020-01-17 01:13:09

问题


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)

Then I tried:

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

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?


回答1:


Can you try this -

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

Is that what you expected?



来源:https://stackoverflow.com/questions/20379798/plotting-the-reciprocal-of-a-sine-wave-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!