Plotting inside a function

2 次查看(过去 30 天)
unfortunately I can't post my code as it is over 300 lines long but it is more a plotting issue. My function works but when I do add fplot in my code like this:
function [Q] = code(L)
%function body
fplot(code(L), [1 5])
end
and when I ran my function I did code(1) assuming after it finished solving for 1 it will plot the graph but it has been only solving for 1 repeatedly.
Any advice.

采纳的回答

Image Analyst
Image Analyst 2018-12-1
That's because the (badly-named) function "code()" calls itself recursively!
That's why code() executes repeatedly.
  4 个评论
Seyifunmi Ayeni
Seyifunmi Ayeni 2018-12-1
I tried that and it seems to work (I'm not getting the same results each time) but when completed no graph pops up.
Walter Roberson
Walter Roberson 2018-12-1
Can you attach your code?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by