Effacer les filtres
Effacer les filtres

Integration of a function

1 vue (au cours des 30 derniers jours)
George
George le 2 Fév 2011
I want to integrate fp(z) with z(0,x). I want an analytic expression.
I have done this:
f2z=@(z) 1./(z.^2+1);
fpz=@(z) f2z(z)./quadl(f2z,0,1);
--> the answer must be:4/(pi*(1 + x^2)) but it doesn't work
sol=int('fpz','z',0,'x')
y=solve('y=sol',x)
xf=@ (y) y ;
and it gives me -->
sol = fpz*x
Warning: Explicit solution could not be found.
In solve at 81
In sampling2 at 81 y = [ empty sym ] ,
(81 line is :y=solve('y=sol',x) )

Réponses (2)

Oleg Komarov
Oleg Komarov le 2 Fév 2011
This is what I get:
syms z
f = 1./(z.^2+1);
sol = f./int(f,z,0,1)
sol =
4/(pi*(z^2 + 1))
Oleg
  1 commentaire
George
George le 2 Fév 2011
Hello,
there is no problem with int(f,z,0,1).The problem is with int(f,z,0,x)

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 2 Fév 2011
sol=int('fpz(z)','z',0,'x'); %different
y = solve(subs('y=sol'),x); %different
A) You cannot use symbolic integration on a function handle.
B) When you create a variable at the Matlab level, then by default it is not known in a quoted string being passed to the MuPad level.
  7 commentaires
George
George le 10 Fév 2011
Sorry,i didn't wrote it right.The result is "4*tan^-1(x)/pi".I can't figure what it's going wrong here!
T
T le 27 Fév 2013
When I attempt to integrate functions with MATLAB, I get an error when I declare the variable:
syms x Undefined function 'syms' for input arguments of type 'char'.
What's wrong?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by