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 日

0 投票

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 日
Thank you for the fast reply. How would I fix this because when i put the fplot after the function t gives me an error saying it should be inside the function. Should it before the function?
Walter Roberson
Walter Roberson 2018 年 12 月 1 日
Does code accept a vector L, and compute a vector of results the same size?
If so, then outside in a different file you would put
fplot(@code, [1 5])
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 件)

カテゴリ

ヘルプ センター および File Exchange2-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