フィルターのクリア

Numerically integrating a symbolic expression

2 ビュー (過去 30 日間)
Ali Baig
Ali Baig 2019 年 2 月 13 日
コメント済み: Ali Baig 2019 年 2 月 13 日
I am trying to integrate a matrix of symbolic entries in which all entries are function of x and y. This matrix is result of previous calculations and cannot be integrated symbolically. I want to numerically integrate it over a rectangluar region between points (-1,-1) , (1,-1), (1,1) and (-1,1). When I use integral2 function, the MATLAB gives following error message:
Error using integral2Calc>integral2t/tensor (line231) ...
A minimum working example is given below:
clear
close
clc
syms x y
f = sin(x) - cos(y)
%This will not work.
fun = @(x, y) f
q = integral(fun, -1, 1, -1, 1)
%This will work.
fun1 = @(x, y) sin(x) - cos(y)
q = integral(fun1, -1, 1, -1, 1)
Since the size of matrix is large (12 x 12) and it is inside a for loop, I cannot manually copy paste and run it.
Regards,
Ali Baig

採用された回答

madhan ravi
madhan ravi 2019 年 2 月 13 日
syms x y
f = matlabFunction(sin(x) - cos(y)); % read about matlabFunction()
q = integral2(f, -1, 1, -1, 1)
which integral2 -all %what shows up?
  1 件のコメント
Ali Baig
Ali Baig 2019 年 2 月 13 日
Dear Madhan
Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by