change variable in function_handle

16 次查看(过去 30 天)
hello all,
i wanna to change x in f=@(x)sinx to x+2 so that we have g=(x)sin(x+2)
how can i derive g from f in matlab?
thanks alot

采纳的回答

the cyclist
the cyclist 2021-5-19
I think this is what you mean?
% Define f
f=@(x) sin(x);
% Derive g from f
g = @(x) f(x+2);
% Show that it gives expected result
f(2)
ans = 0.9093
g(0)
ans = 0.9093

更多回答(1 个)

Sulaymon Eshkabilov
f=@(x)sin(x)
g = @(x)f(x+2)
Good luck

类别

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

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by