How to create function
显示 更早的评论
Hello I am woundering how you do this function;
,om = if, och=and I am supposed to do it with
function f = fun(x,y)
something...
end
Thanks in advance!
3 个评论
David K.
2019-10-1
The general syntax for if , elseif statements is below and should get you on your way. If you get stuck again, post what you have and ask a specific question.
if x>=0 & y>=0
...
elseif x>=0 ...
...
end
Jonathan Larsson
2019-10-1
David K.
2019-10-1
Could you post the code you have and what the error is so that we can help you with that?
If the main problem is that the code you made works outside of a function and not inside, then one of my guesses to what the error could be is that the function and the file name need to be the same. EX. f = fun(x,y) needs to be saved as fun.m
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!