User-defined function is "unrecognized" in command window.

8 vues (au cours des 30 derniers jours)
Sanam Limbu
Sanam Limbu le 5 Nov 2019
Commenté : Ali le 15 Oct 2023
This print_list function works in the script, but it gives the error message "Unrecognized function or variable 'print_list'" in the command window. I am having the same problem with all my other user-defined functions. How can I fix it?
global list list_idx;
list = ["1st", "2nd", "0"];
list_idx = [1, 1, 0];
print_list;
function var = print_list()
global list list_idx;
L = logical(list_idx);
var = list(L);
disp(var);
end

Réponse acceptée

galaxy
galaxy le 5 Nov 2019
You copy only print_list function to other file and save print_list.m in Matlab
It will be OK
  3 commentaires
Sanam Limbu
Sanam Limbu le 5 Nov 2019
Thanks! Also, I figured out that the while calling the function, the name of the file containing the function should be used. In my case, I got errors with print_list() but it worked with function_print_list() since the file name for the function was function_print_list.m.
Ali
Ali le 15 Oct 2023
TY

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by