Can I create function that use default input unless a user gives one?
显示 更早的评论
Hi I want to create function that will use current time to calculate the position of satellites. But later on I will need this function to calculate the satellite position at a few second ahead of the current time for example current time is let's say 50 seconds for the sake of simplicity and I want to update it with 2 second later.
Now I want this function to calculate the sat position at t = 50 seconds by defult unless I give it the 2 second and it adds to the first time. Please check the code structure for better understanding of the uestion
function satposit(time)
if nargin<0
t = 50 % just an example only
s = vt % just an example only
else if nargin>=1
t = 50 + time
s = vt
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Reference Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!