Matrix size error using integral
Mostrar comentarios más antiguos
I am currently trying to compute the Fourier coefficients of a function f(x). For the first coeffficient, I can use integral(f,-l,l) and have no problem with that. For the next coefficient, I define another function which is basically the same as f multiplied by a cos(x). However, if I try integral(f2,-x,x) I get an "Incorrect dimensions for matrix multiplication" error message, which makes no sense since I'm multiplying scalars. Why is this? How can I fix it?
(a,b,k,I0,t,cte are constants previously set)
fun=@(x) sqrt(exp((-(k*a*I0*2*(1+cos(cte*x))/(b+a*2*I0*(1+cos(cte*x)))))*(1-exp(-t(i)*(b+2*a*I0*(1+cos(cte*x)))))));
fun2=@(x) cos(cte*x);
fun3=@(x) fun(x)*fun2(x);
integral(fun3,-1e-7,1e-7)
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in
the second matrix. To operate on each element of the matrix individually, use TIMES (.*) for elementwise multiplication.
Error in fourier>@(x)fun(x)*fun2(x) (line 10)
fun3=@(x) fun(x)*fun2(x);
^
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!