Plotting inside a function

2 vues (au cours des 30 derniers jours)
Seyifunmi Ayeni
Seyifunmi Ayeni le 1 Déc 2018
Commenté : Walter Roberson le 1 Déc 2018
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.

Réponse acceptée

Image Analyst
Image Analyst le 1 Déc 2018
That's because the (badly-named) function "code()" calls itself recursively!
That's why code() executes repeatedly.
  4 commentaires
Seyifunmi Ayeni
Seyifunmi Ayeni le 1 Déc 2018
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 le 1 Déc 2018
Can you attach your code?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by