my problem is about @.

6 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2022-2-3
Note that syms does nothing here. Get rid of it.
Sevval Zengin
Sevval Zengin 2022-2-3
Thank you so much Stephen for your answer.

请先登录,再进行评论。

采纳的回答

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

更多回答(1 个)

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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by