Plotting the reciprocal of a sine wave in MatLab

2019-09-06 10:20发布

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条回答
虎瘦雄心在
2楼-- · 2019-09-06 11:06

Can you try this -

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

enter image description here

Is that what you expected?

查看更多
登录 后发表回答