How do I convert a script to a function?
显示 更早的评论
I am trying to convert the attached script into a function to produce the same figure and results for a plot of the (for argument's sake) Earth orbiting the Sun. I have attached what I have of the function so far, but I am struggling to understand what I have done wrong and how to proceed. The function has pseudocode explanations of variables etc. Any help would be much appreciated. Regards, AR
4 个评论
Rik
2017-5-3
There isn't really that much of a difference in this case between a function and a script. The main differences are execution speed optimization and workspace management. So once you have a working script, just add the function line at the top, an end at the bottom, and move some definitions from code to input.
It looks like you are already there. What is your problem exactly?
Jan
2017-5-3
Whenever you mention in the forum, that you assume something is going wrong, explain the details. Why do you think, that you have done something wrong? It is much easier to solve a problem than to guessm what the problem is.
Ashley Rains
2017-5-3
Ashley Rains
2017-5-4
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!