Need help with matlab code for below mentioned integrals

I want to know how to write the code for below two integrals
1.) If , then how to write the matlab code for .
2.) If , then how to write the matlab code for .

4 件のコメント

Dyuman Joshi
Dyuman Joshi 2023 年 3 月 15 日
What have you tried yet? Please show your code.
Nikhil
Nikhil 2023 年 3 月 15 日
@Dyuman Joshi I don't know from where to begin actually I was trying the inbuilt matlab function like trapz for trapizoidal rule and conv(f,g) for convolution but it didn't work. I guess these function work only if function is of single variable. Since in my case function is of two variable I don't know how to integrate wrt one variable.
Dyuman Joshi
Dyuman Joshi 2023 年 3 月 15 日
conv and trapz only supports numeric data.
Are you sure you have to use trapezoidal rule? You can achieve the result of the integration without using it.
Nikhil
Nikhil 2023 年 3 月 15 日
Okay Sir, if you know another way to calculate these two integral can you please help?

サインインしてコメントする。

 採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 3 月 15 日

1 投票

Note that you need symbolic toolbox to run this code -
syms a b x y tau
%Defining functions
r(a,b) = exp(-a-b);
f(a,x) = exp(-0.09*a) + (sin(0.05*x))^2;
K(x) = exp(-x^2)/sqrt(sym(pi));
P = int(r(a,tau)*f(tau,x), tau, 0, 50)
P = 
%To calculate the value of the integral for particular values of a and x
%use subs,
P_val = subs(P, [a,x], [1,0])
P_val = 
J = int(K(x-y)*f(a,y), y, 0, 50)
J = 
J_val=subs(J, [a,x], [1,0])
J_val = 
For J, int() is unable to compute the value of the definite integral. However, you can get the approximate numerical value by using vpa
J_valapprox=vpa(J_val)
J_valapprox = 
0.45758981203624906236445682215257

その他の回答 (0 件)

カテゴリ

質問済み:

2023 年 3 月 15 日

編集済み:

2023 年 3 月 16 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by