フィルターのクリア

Matlab says, I reached the max limit of recursion: " Maximum recursion limit of 500 reached. "

2 ビュー (過去 30 日間)
Here's my code from Help Manual:
x = randn(100,1);
y = randn(100,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = Histogram2(x,y,Xedges,Yedges)
Apparently there's some other conditions that need to be established before I can run this example code from Help manual, but being new to Matlab, I can' figure this out.
Appreciate any help you can provide.
Thanks,
Stephen
  3 件のコメント
Chunru
Chunru 2021 年 7 月 23 日
編集済み: Chunru 2021 年 7 月 23 日
Try "which newfunction" after error occurs and identify what the "newfunction" is. It is the "newfunction" that gives the trouble.
Image Analyst
Image Analyst 2021 年 7 月 23 日
編集済み: Image Analyst 2021 年 7 月 23 日
@Chunru, like I said in my second answer below, if newfunction is the name of his m-file, there may be only one, but it's being called recursively. Fixes are in my answer below.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2021 年 7 月 23 日
newfunction()
x = randn(100,1);
y = randn(100,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = histogram2(x,y,Xedges,Yedges)
So, that's the full code? Your m-file is not by any chance called "newfunction.m" is it? Because the first line of newfunction would call itself recursively, like I tried explain to you in my first answer. To fix, either comment out that first line,
% newfunction()
x = randn(100,1);
y = randn(100,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = histogram2(x,y,Xedges,Yedges)
or put the function keyword in front of it
function newfunction()
x = randn(100,1);
y = randn(100,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = histogram2(x,y,Xedges,Yedges)
  2 件のコメント
Stephen
Stephen 2021 年 7 月 23 日
Thank you, that fixed it!
As the Chinese proverb goes, 'ask the question and appear foolish for a day, than not ask and remain a fool for life'
Image Analyst
Image Analyst 2021 年 7 月 23 日
You're welcome. Thanks for accepting the answer.

サインインしてコメントする。

その他の回答 (2 件)

Image Analyst
Image Analyst 2021 年 7 月 23 日
Once I changed Histogram2 to histogram2 (MATLAB is case sensitive), it works fine:
x = randn(100,1);
y = randn(100,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = histogram2(x,y,Xedges,Yedges)
I suspect that your m-file is called Histogram2.m and that it's calling itself. It recurses deeper and deeper with no way to back out, until it eventually calls itself 500 times and throws that error you saw.
Correct the name to histogram2, and change the name of your m-file to something like test_histogram.m instead of Histogram2.m.

Chunru
Chunru 2021 年 7 月 23 日
Try "clear all" before running the code. Change "Histogram2" to "histogram2" (case sensitive). It seems there is no recursive function in the code. If the problem cannot be resolved, do "dbstop error" before running the code and observe the error message.
x = randn(100,1);
y = randn(100,1);
Xedges = [-Inf -2:0.4:2 Inf];
Yedges = [-Inf -2:0.4:2 Inf];
h = histogram2(x,y,Xedges,Yedges);

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by