How can ı call this void function from another file.I could not do it
이전 댓글 표시
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
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
2020년 5월 4일
dpb
2020년 5월 4일
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...
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Octave에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!