Triplequad function with symbolic variables

2 ビュー (過去 30 日間)
Kazim
Kazim 2013 年 3 月 2 日
Hi Dear Matlab users
My problem is I wrote a function just below.
function out = ahmet(r,s,zeta)
syms z1
out=2*r.^2*s.^4*zeta*z1;
end
Then I called this function to be used for
k=triplequad('ahmet',-1,1,-1,1,-1,1)
It gives me errors telling that ''Inputs must be floats, namely single or double.''
If I omit z1 variable which is symbolic then it evaluates the quadrature but I want z1 stay and not calculated in the equation. Is it possible for quadrature ?
It is possible for int() command using symbolic variables. But I have to bring together both quadrature and symbolic variables ?
Thank you

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 3 月 2 日
syms r s zeta
k = int( int( int( ahmet(r, s, zeta), r, -1, 1), s, -1, 1), zeta, -1, 1);
Note that the result (if it can be analytically found) will likely have z1 as a free variable.
Caution: if you replace the limits of integration for zeta with "a" and "b", the integral works out as (4/15)*z1*(b^2-a^2) . And when abs(a) = abs(b) as is the case for -1 to +1, the solution is going to be identically 0 for all values of z1.
  1 件のコメント
Kazim
Kazim 2013 年 3 月 3 日
Thank you Mr. Walter Roberson I tried your solution but my function is more complicated and when I used int it says explicit integral can not be found. For this reason I decided to use quadrature.
I have found quadl below. It says additional arguments p1,p2 to be passed directly to function. Could we use it ?
quadl(fun,a,b,tol,trace,p1,p2,...) provides for additional arguments p1,p2,... to be passed directly to function fun, fun(x,p1,p2,...). Pass empty matrices for tol or trace to use the default values
For example; quadl('ahmet',-1,1,[],[],s,zeta,z1)
function out = ahmet(r,s,zeta,z1)
out=2*r.^2*s.^4*zeta*z1;
end
function out = ahmet(r,s,zeta,z1)----> Here I have a problem for input arguments sequence ? Because quadl uses ahmets r input for -1 and 1 then tol and trace comes then I think if I have to empty two matrix for tol and trace parts in ahmet function input arguments like ahmet(r,[],[],s,zeta,z1) ?
Thank you

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by