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.

59 次查看(过去 30 天)
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,[]);

采纳的回答

Image Analyst
Image Analyst 2017-2-11
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 个评论
Jan
Jan 2017-2-12
@DB talari: Image Analyst's suggestions are valuable. Please consider them, because this will help readers to answer your questions efficiently in the future.

请先登录,再进行评论。

更多回答(2 个)

Jan
Jan 2017-2-12
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.
  5 个评论
Image Analyst
Image Analyst 2024-5-30
For one thing, the whole thing is commented out so I don't see how any errors could be produced. Then right after you assign line_data, you call clear all, essentially getting rid of all variables assigned up to that point.
What do you think you're passing in for x when you call forward()?
DGM
DGM 2024-5-30
If you were getting the same error, then the answer to that problem has already been given. Either way, if you've read the thread enough to suspect it's similar, then you should have noticed that it's up to you to tell us what the error message actually is. You haven't done that.
What you pasted is entirely commented out. It will produce no errors, because it can't be executed. Even if the first layer of comments is removed, we still can't run your code, because we don't know what the inputs are, and we don't have the following functions/variables:
  • linedata_radial_bus
  • busdata_radial_bus
My suspicion is that you're trying to use the literal variables linedata and busdata33 in their place, but you never actually changed the code. As a side note, those two variables are unequal lengths, so you'll get indexing errors if you tried to index into the 33rd row -- but the code doesn't actually do subscript addressing. It just gets the 33rd element, which is either the number 33 or the number 1, which is almost certainly also wrong.
In other words, nobody knows what you're trying to do or what error you got. It could have been none, or any number of other errors, but it probably wasn't the error relevant to this thread.

请先登录,再进行评论。


Jay shankar Nanda
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 个评论
Stephen23
Stephen23 2021-3-9
编辑:Stephen23 2021-3-9
@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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by