MATLAB plotting undefined points
5 views (last 30 days)
Show older comments
Patrick Faulkner
on 17 Oct 2023
Commented: Patrick Faulkner
on 17 Oct 2023
I'm trying to generate plots with trigonometric functions, but MATLAB keeps drawing points that are undefined. In this case, for csc(x), it is generating vertical lines (not simply asymptotes) at all positive multiples of pi.
I have tried modifying my code so it only plots up to pi-0.1, the starts again at pi+0.1. I have gone to several decimals, but this way I can't get asymptotes, only gaps. I'm trying to get functions with the asymptotes and without those undefined points being graphed.
Bad plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1513699/image.png)
fairly normal code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1513704/image.png)
0 Comments
Accepted Answer
Dyuman Joshi
on 17 Oct 2023
An alternative is to use the corresponding numeric functions -
figure
fplot(@csc, [-10 10], 'b')
hold on
fplot(@sin, [-10 10], 'r')
As to the reason, why the output from the symbolic csc function is such, I do not have an explaination at the moment.
And, the plot/behaviour of symbolic csc function with one of the plot interval specified as a multiple of pi is weird -
syms x
figure
%Example taken from the documentation of symbolic csc function
fplot(csc(x),[-4*pi 4*pi],'b')
grid on
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!