problem with integration of a function
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Chloe St John
 el 26 de En. de 2019
  
    
    
    
    
    Respondida: madhan ravi
      
      
 el 26 de En. de 2019
            I have created a user-defined function for yb(x)=10x^2exp(-2x)[sin(3x-pi)+cos(x^2)]
code shown below (saved as b3.m) :
function [yb] = b3(x)
yb = 10*x.^2*exp(-2*x).*(sin(3*x-pi)+cos(x.^2))
end
now trying to find integral of function and my code is:
intb3=integral(@b3,0,5)
this comes up in my command window:
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 perform elementwise multiplication, use
'.*'.
Error in b3 (line 2)
yb = 10*x.^2*exp(-2*x).*(sin(3*x-pi)+cos(x.^2))
Error in integralCalc/iterateScalarValued (line
314)
                fx = FUN(t);
Error in integralCalc/vadapt (line 132)
            [q,errbnd] =
            iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
        [q,errbnd] =
        vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in b4 (line 4)
intb3=integral(@b3,0,5)
Respuesta aceptada
  madhan ravi
      
      
 el 26 de En. de 2019
        yb = 10*x.^2.*exp(-2*x).*(sin(3*x-pi)+cos(x.^2))
     %      ^--- missed it
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

