how to define a function in the command window using "@"

I have seen this before but I can't remember. Can someone give an example? Thanks.

 Accepted Answer

please read here
eg
>> f = @(x)x.^2-3
f(54)
f =
@(x)x.^2-3
ans =
2913

2 Comments

Can this be done (@x) sin(x)-exp(-x)
Moving the first left parenthesis to its proper place, sure.
f = @(x) sin(x)-exp(-x);
f(-1:0.25:1)

Sign in to comment.

More Answers (0)

Categories

Find more on Geology in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

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

Start Hunting!