my problem is about @.

5 visualizaciones (últimos 30 días)
Sevval Zengin
Sevval Zengin el 3 de Feb. de 2022
Comentada: Sevval Zengin el 3 de Feb. de 2022
syms x
f=@x x.^2
quad(f,0,2)
System give error that 'Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.'
.....................................................................................................................................................................................................................................
PLEASE HELP ME
  2 comentarios
Stephen23
Stephen23 el 3 de Feb. de 2022
Note that syms does nothing here. Get rid of it.
Sevval Zengin
Sevval Zengin el 3 de Feb. de 2022
Thank you so much Stephen for your answer.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 3 de Feb. de 2022
Editada: Stephen23 el 3 de Feb. de 2022
f = @(x) x.^2;
% ^ ^ you forgot these parentheses
q = quad(f,1,2)
q = 2.3333
How to define anonymous functions is explained here:

Más respuestas (1)

Arif Hoq
Arif Hoq el 3 de Feb. de 2022
try it:
syms x
f=@(x) x.^2
f = function_handle with value:
@(x)x.^2
quad(f,0,2)
ans = 2.6667
  2 comentarios
Stephen23
Stephen23 el 3 de Feb. de 2022
Note that syms does nothing here.
Sevval Zengin
Sevval Zengin el 3 de Feb. de 2022
thank youuu so much

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by