i am trying to integrate a power sum raised to power of 1.2.
The question is this integrate (((t^1)+(t^2)+(t^3))^(1.2)) from 0 to 1, with respect to t.
x=1:3
syms t
y=sum(t.^x)
fun=@(y) y^(1.2)
integral(fun,0,1)
Output as: Error using ^ Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.
But I'm not trying to compute elementwise.
Any comment/insight would be helpful. Thank you.
I think, in your last line you refer to the generic y
that has nothing to do with y
you have specified before. so, instead of fun
you need fun(y)
. Then, since the output of your fun
is symbolic expression, then you need to convert this expression to the function handle using matlabFunction
. So, the final code would look like:
x=1:3
syms t
y=sum(t.^x)
fun=@(y) y^(1.2)
integral(matlabFunction(fun(y)),0,1)
Output:
1.1857
Hope that helps, good luck!