How to get the y values for a given function and x values

1 view (last 30 days)
I need the y values for a given function and x values. This is what I have, but it doesn't work:
x = [1.99:0.00004:2.01];
f = @(x) (x-2).^7
y2 = fnval( f,x);
thanks for the help

Accepted Answer

Thorsten
Thorsten on 1 Oct 2014
Edited: Thorsten on 1 Oct 2014
It's a typo. You have to use
y2 = feval(f, x);
You could also directly write
y2 = (x-2).^7;

More Answers (2)

Star Strider
Star Strider on 1 Oct 2014
You can simply evaluate it directly as a function:
x = [1.99:0.00004:2.01];
f = @(x) (x-2).^7;
y2 = f(x);
figure(1)
plot(x, y2)
grid

Timothy
Timothy on 1 Oct 2014
Cheers guys!

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!