From: Alex Sergeevich on
Hi all!

I have a program in matlab which essentially should do following:

P=1;
syms x;
for k=1:10
norm = quad(@(x)P.*(cos(m.*x)).^2, 0, pi/2);
P = (P*(cos(m*x))^2)/norm;
display(norm);
end;

But it is not working:
??? Undefined function or method 'isfinite' for input arguments of type 'sym'.

Can someone tell me what is wrong here?

Thanks..
From: Alex on
And when I have
norm = quad(@(x)'P'.*(cos(m.*x)).^2, 0, pi/2);
instead of
norm = quad(@(x)P.*(cos(m.*x)).^2, 0, pi/2);
it shows me "Singularity possible"
From: Steven Lord on

"Alex Sergeevich" <a.sergeevich(a)gmail.com> wrote in message
news:i0ea0f$pog$1(a)fred.mathworks.com...
> Hi all!
>
> I have a program in matlab which essentially should do following:
>
> P=1;
> syms x;
> for k=1:10
> norm = quad(@(x)P.*(cos(m.*x)).^2, 0, pi/2);
> P = (P*(cos(m*x))^2)/norm;

After the k = 1 iteration, P becomes a symbolic expression. Then at k = 2,
you're attempting to use QUAD to integrate a symbolic expression.

QUAD does NOT work for symbolic integration. Use the INT function to
perform symbolic integration.

*snip*

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Alex on
> After the k = 1 iteration, P becomes a symbolic expression. Then at k = 2,
> you're attempting to use QUAD to integrate a symbolic expression.
>
> QUAD does NOT work for symbolic integration. Use the INT function to
> perform symbolic integration.

Yes, but I want to integrate it by x. There is x into the expression and x hidden into P. I don't understand why it integrates by x directly but can't do it when it is 'into' P...

I don't need symbolic integration. (Sorry, that 'm' parameter there is a number, you can think of it as 1). Numeric result...

I didn't use 'int' since in actual program the expression is quite large and this function just integrates it forever... Never got any answer from it...