Reputation: 485
This looks really simple. I want to define a function:
syms x
f = x^2
I want to be able to do f(4) and it spits out 16. I also want to avoid having to write a new m-file.
f(4)
Upvotes: 2
Views: 93
Reputation: 10676
When dealing with symbolic variables, to substitute in a numeric value, use subs(), i.e. symbolic substitution:
subs()
syms x f = x^2 subs(f,4)
Upvotes: 5
Reputation: 500883
>> f = @(x) x^2; >> f(4) ans = 16
Upvotes: 4