Plotting symbolic equation along an array.
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to plot the symbolic function: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1159743/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1159743/image.png)
I have expressed the function using syms for f(x),x,n
the trouble I am having is with x, x is a value from 0<x<L. where L is a arbitrary number. 100 for example.
how would I plot 0:L on the x axis and the function of f(x) on the y axis. for each n.
thank you for the help.
heres what I got so far with my script
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1159748/image.png)
댓글 수: 0
답변 (1개)
Torsten
2022년 10월 17일
Is the really the function you calculated the Fourier series of ?
L = 10;
nx = 100;
nmax = 200;
x = (linspace(0,L,nx)).';
n = 1:nmax;
f = ((-1).^n-1)./(n.^2*pi) .* cos(n.*x) + (1-2*(-1).^n)./n .* sin(n.*x);
values = -pi/4 + sum(f,2);
plot(x,values)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!