Undefined function or variable "new_m"

Dear all,
I am new to Matlab. I have three functions. When I call co.m and pol_det.m they both work fine. However, when I call minor.m which in itself calls pol_det which in its turn calls co.m I get an error referring to the co.m: Undefined function or variable "new_m".
All the three functions are attached. I am working with R2007b version.
Thank you in advance.

Respuestas (1)

Star Strider
Star Strider el 5 de Mzo. de 2019
Editada: Star Strider el 5 de Mzo. de 2019
In the ‘co.m’ code, you commented out the preallocation of ‘new_m’:
. . .
%create a new matrix by eliminating the row and column in which the %element is present
%new_m=zeros(m,n)
row=1;
. . .
So it doesn’t exist when you first want to use it.
The solution will probably be to remove the comment percent-sign in that line:
%create a new matrix by eliminating the row and column in which the %element is present
new_m=zeros(m,n)
row=1;

2 comentarios

Hi, thank you for the suggestion. Unfortunately, it does not help but rather makes me achieve the limit of some iterations...
??? Maximum recursion limit of 500 reached. Use
set(0,'RecursionLimit',N)
It prints out new_m=0 apparently 500 times...
That was my original idea to introduce an empty matrix but it leads to other errors.
Star Strider
Star Strider el 5 de Mzo. de 2019
You have a function calling a function calling the function that called it, so ‘pol_det’ calls ‘co’ that calls ’pol_det’ that calls ‘co’ ... ad infinitum.
That is causing the infinte recursion.

La pregunta está cerrada.

Preguntada:

el 5 de Mzo. de 2019

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by