Out of memory. The likely cause is an infinite recursion within the program.

조회 수: 1 (최근 30일)
function [x,n] = secuno(n0,n1,n2)
% Genera x[n] = u[n ¡ n0]; n1 <= n <= n2
% %
[x,n] = secuno(n0,n1,n2)
% %
[x,n] = secuno(n0,n1,n2)
%
n = [n1:n2]; x = [(n-n0) >= 0];
___________________________________________
% Obtención de h[m]
n = [-10:10];
h = secuno(10,0,20);
subplot(2,2,1), stem(n,h,'b','linewidth',2);
grid
title('Respuesta al impulso h[m]');
xlabel('m');
axis([-10,10,0 1.1]);
text(0,-0.2,'(a)');
% Obtención de la transpuesta de h[m]
[ht,nt] = transpon(h,n);
subplot(2,2,2), stem(nt,ht,'b','linewidth',2);
grid
title('Respuesta al impulso reflejada h[¡m]');
xlabel('m');
axis([-10,10,0 1.1]);
text(0,-0.2,'(b)');
% Obtención del corrimiento o desplazamiento
[hd,nd] = desplaza(ht,nt,5);
subplot(2,2,3), stem(nd,hd,'b','linewidth',2);
grid
title('Respuesta al impulso desplazada h[5 - m]');
xlabel('m');
axis([-5 15 0 1.1]);
text(5,-0.2,'(c)');
% Obtención de x[n]
x = n.*secuno(10,0,20);
subplot(2,2,4), stem(n,x,'b','linewidth',2);
grid
title('Secuencia de entrada x[m]');
xlabel('m');
text(0,-2,'(d)');
  댓글 수: 1
LUIS ENRIQUE CHUQUIMARCA JIMENEZ
Out of memory. The likely cause is an infinite recursion within the program.
Error in secuno (line 4)
[x,n] = secuno(n0,n1,n2)

댓글을 달려면 로그인하십시오.

채택된 답변

Steven Lord
Steven Lord 2021년 6월 2일
Let's look at the first couple lines of your function.
function [x,n] = secuno(n0,n1,n2)
% Genera x[n] = u[n ¡ n0]; n1 <= n <= n2
% %
[x,n] = secuno(n0,n1,n2)
So if you call secuno with three inputs, the very first thing secuno does is call secuno with those same three inputs.
The very first thing that call to secuno does is call secuno with those same three inputs.
The very first thing that call to secuno does is call secuno with those same three inputs.
The very first thing that call to secuno does is call secuno with those same three inputs.
The very first thing that call to secuno does is call secuno with those same three inputs.
etc.
Eventually MATLAB throws an error or crashes, depending on how large you've set the recursion limit and how much stack space you have.
Don't have secuno call itself, or if you must have secuno call itself recursively there must be a code path where secuno doesn't call itself, the base case(s).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by