- Define a new function such that f2(x) is always 10 greater than f(x), for all values of x
- Find the value of f(x) at a particular value of x, and add 10 to that
- Something else [please describe]
Adding a function with a specific value
1 次查看(过去 30 天)
显示 更早的评论
Hello. I am trying to add a simple value to a function, but it rejects me every time. I think i've tried every noob idea, and was all out of luck. What am i missing?
f=@(x) x^4-7*x^3+9*x^2+7*x-5;
f+10
2 个评论
the cyclist
2021-3-9
Which of the following is what you want?
回答(1 个)
Jan
2021-3-9
You define f as a function handle. Then you have to call it with an argument also:
f = @(x) x^4 - 7 * x^3 + 9 * x^2 + 7 * x - 5;
f(5) + 10 % 15
Or do you want to create another function?
g = @(x) f(x) + 10
g(5) % Of course also 15
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!