![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/344880/image.jpeg)
how to write code for intergral with two variables?
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to plot this function
f={(1+cos(w))*cos(w*x)}/(pi^2-w^2)+sin(w)*sin(w*x)/(pi^2-w^2)
int(f,w,0,n)
so i wrote code for this function
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
x=-3:0.01:3;
syms w
A=(1+cos(w))*cos(w*x);
B=sin(w)*sin(w*x);
C=pi^2-w^2;
f=A/C+B/C;
F5=int(f,'w',0,5)
plot(x,F5)
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
then the process did not finish. what's wrong on my code?
and how to plot this function?
댓글 수: 0
답변 (1개)
Surya Talluri
2020년 8월 12일
I understand that you are trying to get integral values at 600 values of x, which is taking so much time to run. You can use “fplot” function to plot any symbolic expressions in required interval.
syms w x
pi = sym(pi)
A=(1+cos(w))*cos(w*x);
B=sin(w)*sin(w*x);
C=pi^2-w^2;
f=A/C+B/C
F5=int(f,w,0,5)
fplot(F5, [-3, 3])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/344880/image.jpeg)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 미적분에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!