Maximum recursion limit of 500 reached. Use set(0,'Rec​ursionLimi​t',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.

62 visualizaciones (últimos 30 días)
it's fine working on another laptop but in my laptop will getting above error.........? can any one solve this....?
clear all;
close all;
a=imread('indus.jpg');
b=rgb2gray(a);
[m,n]=size(b);
r=im2double(b);
% r=im2bw(b,0.75);
% ^r=b;
out=r;
for i=2:m-1
for j=2:n-1
h=[1*r(i-1,j-1) 1*r(i-1,j) 1*r(i-1,j+1);...
1*r(i,j-1) 1*r(i,j) 1*r(i,j+1);...
1*r(i+1,j-1) 1*r(i+1,j) 1*r(i+1,j+1)];
out(i,j)=(median(median(h)));
end
end
r=out;
sobel=r;
for i=2:m-1
for j=2:n-1
h=[-1*r(i-1,j-1) 0*r(i-1,j) 1*r(i-1,j+1);...
-2*r(i,j-1) 0*r(i,j) 2*r(i,j+1);...
-1*r(i+1,j-1) 0*r(i+1,j) 1*r(i+1,j+1)];
sobel(i,j)=(mean(mean(h)));
end
end
sobel1=sobel;
for i=2:m-1
for j=2:n-1
h=[-1*sobel(i-1,j-1) -2*sobel(i-1,j) -1*sobel(i-1,j+1);...
0*sobel(i,j-1) 0*sobel(i,j) 0*sobel(i,j+1);...
1*sobel(i+1,j-1) 2*sobel(i+1,j) 1*sobel(i+1,j+1)];
sobel1(i,j)=(mean(mean(h)));
end
end
% a=min(r,sobel1);
% figure,imshow(a);
res=max(sobel1,r);
figure,imshow(res);
subplot(221);imshow(r,[]);
subplot(222);imshow(res,[]);
subplot(223);imshow(sobel,[]);
subplot(224);imshow(sobel1,[]);

Respuesta aceptada

Image Analyst
Image Analyst el 11 de Feb. de 2017
First, read this link to fix the formatting.
If you picked a name of your script that is the same as some function in your script, it will be called recursively, just as your partial error message states.
It's likely you called your script mean.m, sobel.m, or median.m.
I'm not sure because you didn't attach it, nor did you include the complete error message ( ALL the red text including the parts that identify the line of code throwing the error), nor did you tell us the name of your script.
  4 comentarios
Jan
Jan el 12 de Feb. de 2017
@DB talari: Image Analyst's suggestions are valuable. Please consider them, because this will help readers to answer your questions efficiently in the future.
Jan
Jan el 29 de Jun. de 2017
Editada: Jan el 29 de Jun. de 2017
I've unaccepted my answer and accepted this one.

Iniciar sesión para comentar.

Más respuestas (2)

Jan
Jan el 12 de Feb. de 2017
Start with omitting the brute clearing header: "clear all; close all". This wastes time and is not useful in productive code.
An improtant detail is missing in the error message: Which line causes the error? This line will contain the name of the function, which is called recursively. I assume this will be the name of the script file you have posted.
  2 comentarios
SUSHMA MB
SUSHMA MB el 29 de Jun. de 2017
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in reducem>dpalg
How to resolve this error?
Walter Roberson
Walter Roberson el 29 de Jun. de 2017
SUSHMA MB: We need to see your code, and we need to know the file name you are using for your code.

Iniciar sesión para comentar.


Jay shankar Nanda
Jay shankar Nanda el 9 de Mzo. de 2021
function [x,P]=ekf(fstate,x,P,hmeas,z,Q,R)
% EKF Extended Kalman Filter for nonlinear dynamic systems
% [x, P] = ekf(f,x,P,h,z,Q,R) returns state estimate, x and state covariance, P
% for nonlinear dynamic system:
% x_k+1 = f(x_k) + w_k
% z_k = h(x_k) + v_k
% where w ~ N(0,Q) meaning w is gaussian noise with covariance Q
% v ~ N(0,R) meaning v is gaussian noise with covariance R
% Inputs: f: function handle for f(x)
% x: "a priori" state estimate
% P: "a priori" estimated state covariance
% h: fanction handle for h(x)
% z: current measurement
% Q: process noise covariance
% R: measurement noise covariance
% Output: x: "a posteriori" state estimate
% P: "a posteriori" state covariance
%
% Example:
n=3; %number of state
q=0.1; %std of process
r=0.1; %std of measurement
Q=q^2*eye(n); % covariance of process
R=r^2; % covariance of measurement
f=@(x)[x(2);x(3);0.05*x(1)*(x(2)+x(3))]; % nonlinear state equations
h=@(x)x(1); % measurement equation
s=[0;0;1]; % initial state
x=s+q*randn(3,1); %initial state % initial state with noise
P = eye(n); % initial state covraiance
N=20; % total dynamic steps
xV = zeros(n,N); %estmate % allocate memory
sV = zeros(n,N); %actual
zV = zeros(1,N);
for k=1:N
z = h(s) + r*randn; % measurments
sV(:,k)= s; % save actual state
zV(k) = z; % save measurment
[x, P] = ekf(f,x,P,h,z,Q,R); % ekf
xV(:,k) = x; % save estimate
s = f(s) + q*randn(3,1); % update process
end
for k=1:3 % plot results
subplot(3,1,k)
plot(1:N, sV(k,:), '-', 1:N, xV(k,:), '--')
end
%}
% By Yi Cao at Cranfield University, 02/01/2008
%
[x1,A]=jaccsd(fstate,x); %nonlinear update and linearization at current state
P=A*P*A'+Q; %partial update
[z1,H]=jaccsd(hmeas,x1); %nonlinear measurement and linearization
P12=P*H'; %cross covariance
% K=P12*inv(H*P12+R); %Kalman filter gain
% x=x1+K*(z-z1); %state estimate
% P=P-K*P12'; %state covariance matrix
R=chol(H*P12+R); %Cholesky factorization
U=P12/R; %K=U/R'; Faster because of back substitution
x=x1+U*(R'\(z-z1)); %Back substitution to get state update
P=P-U*U'; %Covariance update, U*U'=P12/R/R'*P12'=K*P12.
function [z,A]=jaccsd(fun,x)
% JACCSD Jacobian through complex step differentiation
% [z J] = jaccsd(f,x)
% z = f(x)
% J = f'(x)
%
z=fun(x);
n=numel(x);
m=numel(z);
A=zeros(m,n);
h=n*eps;
for k=1:n
x1=x;
x1(k)=x1(k)+h*i;
A(:,k)=imag(fun(x1))/h;
end
The same error is showing to me kindly tell how to fix it
  1 comentario
Stephen23
Stephen23 el 9 de Mzo. de 2021
Editada: Stephen23 el 9 de Mzo. de 2021
@Jay shankar Nanda: Note that inside ekf you call ekf. So when you first call ekf, it will run until the line where it calls ekf. Then it will call ekf, and run until it reaches the line where it calls ekf. Then it will call ekf, and run until it reaches the line where it calls ekf. Then it will call ekf, and run until it reaches the line where it calls ekf. Then it will call ekf, and run until it reaches the line where it calls ekf. Then it will call ekf, and run until it reaches the line where it calls ekf... etc., until your code reaches the recursion limit.
Is that your intent?
Note that your main functions inputs are all/mostly ignored within the function. It looks as if the main function should be renamed or perhaps converted to a script.

Iniciar sesión para comentar.

Categorías

Más información sobre Particle Swarm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by