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

2 views (last 30 days)
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 Comment
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)

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 2 Jun 2021
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).

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!