![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175689/image.png)
Problem plotting sinc function.
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi, I'd like to plot the following function: 400/pi*sinc^2(20sin(x))*cos^2(x) for x between -0.5 and 0.5. To that end, I wrote the following code, which unfortunately doesn't yield a result similar to that in attached image:
x = -0.5:0.1:0.5;
plot(x,(400/pi)*(cos(x*pi)).^2.*(sinc(20*sin(x*pi))).^2);
I get a triangular graph instead with no sinusoidal decay. I'd appreciate some assistance with this simple task.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/158399/image.jpeg)
댓글 수: 0
채택된 답변
Stephen23
2016년 11월 27일
편집: Stephen23
2016년 11월 27일
There is no problem with your function, however you only calculated eleven data points (check the length of x), which gives a very triangular plot because it cannot represent the detail of the curve that you want. You need to increase how many points you calculate, such as this which generates one hundred and one data points:
x = -0.5:0.01:0.5; % <- changed the step to 0.01
y = (400/pi)*cos(x*pi).^2.*sinc(20*sin(x*pi)).^2;
plot(x,y);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175689/image.png)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!