How to Integrate the equation with function handler?

%% Thank you in advance!!
clc;
clear;
close all;
syms omega1
n=2;
a1=1;
x=2;
y=2;
G_2=5;
Q_2=0;
A_hs =-G_2/omega1^2;
B_hs =(-G_2*abs(omega1) - Q_2*1i*omega1)/omega1^2;
Phi=(A_hs+B_hs.*x).*exp(-abs(omega1).*x);
f=@(omega1) A_hs.*(exp(-x*abs(omega1))).*exp(-1i.*omega1.*y);
sigma_xx=(integral(f,-2,2))
### showing Some error in calculation

回答 (1 件)

Ioannis Matthaiou
Ioannis Matthaiou 2021 年 4 月 15 日

1 投票

The command can be as follows:
sigma_xx=ode45(@(t,omega1) f(t,omega1,x,y), tspan, ICs, options)
The function to integrate as follows:
function sigma_x = f(t,omega1,x,y)
sigma_x = A_hs.*(exp(-x*abs(omega1))).*exp(-1i.*omega1.*y);
end

3 件のコメント

gourav pandey
gourav pandey 2021 年 4 月 15 日
after running your code i got another error, "Unrecognized function or variable 'tspan, ICs, options "
gourav pandey
gourav pandey 2021 年 4 月 15 日
one more doubt i have. why we have 't' in the code?
Ioannis Matthaiou
Ioannis Matthaiou 2021 年 4 月 15 日
Hello,
Please read the following official documentation: https://uk.mathworks.com/help/matlab/ref/ode45.html

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

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2021a

質問済み:

2021 年 4 月 15 日

コメント済み:

2021 年 4 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by