Creating a function in MATLAB
1 次查看(过去 30 天)
显示 更早的评论
Here is my question. I feel like this is an easy task but somehow cannot create a function to do this for me.
Create a function which given a value x, returns a value f(x) according the
following equation:
f(x)=xsin(x).
Thanks for the help!
0 个评论
采纳的回答
Azzi Abdelmalek
2013-2-2
编辑:Azzi Abdelmalek
2013-2-2
f=@(x) x*sin(x)
%or
function y=f(x)
y=x*sin(x)
0 个评论
更多回答(1 个)
Image Analyst
2013-2-2
Is this homework? Did you look up how to define functions in the help? Do you know that you need to use ".*" between the x and the sin?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!