How can ı call this void function from another file.I could not do it
Afficher commentaires plus anciens
function [] = palindromeprime(n)
reverse = 0;
new = n;
prime = n;
x = true;
while new > 0
t = mod(new,10);
reverse = 10*reverse+t;
new= (new-t)/10;
end
for i = 2:(prime - 1)
if mod(prime,i) == 0
x = false;
break;
end
end
if(n == reverse && x == true)
fprintf("This is a palindrome prime number");
else
fprintf("This is NOT a palindrome prime number");
end
3 commentaires
Just like any other MATLAB function or script...
palindromeprime
from the command line or in a script.
What did you try and what was the error message returned?
It does have to be in a directory on MATLABPATH or in your current working directory to be found...
Kaan Kara
le 4 Mai 2020
dpb
le 4 Mai 2020
Well, that indicates that the function file name either is misspelled maybe or that the location for it is not in either the working directory or on the MATLABPATH.
What does
which -all palindromeprime
return from the location from which you run the other function?
We can't see that function -- does it, by any chance, change the working directory inside it in order to find some data files? Something like that can break it because move away from the location where the m-file is located.
Without all the information in context, all we can do is guess...
Réponses (0)
Catégories
En savoir plus sur Octave dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!