FUNCTION NAME AND SCRIPT NAME

21 visualizzazioni (ultimi 30 giorni)
Setayesh Asadifard
Setayesh Asadifard il 19 Dic 2021
Risposto: Walter Roberson il 19 Dic 2021
A=1;
B=2;
C=3;
enKucukSayi=UcSayininMinimumunuBul1(A,B,C);
function enKucukSayi=UcSayininMinimumunuBul1(A,B,C)
if A<B && A<C
enKucukSayi=A;
elseif B<A && B<C
enKucukSayi=B;
else
enKucukSayi=C;
end
end
THIS IS THE CODE THAT I WROTE TO FIND THE MINIMUM NUMBER
Error: File: UcSayininMinimumunuBul1.m Line: 5 Column: 22
Local function name must be different from the script name.
AND THIS IS THE ERROR THAT PROGRAM SHOWS TO ME
WHAT SHOULD I DO OR CHANGE IN MY CODES?

Risposte (1)

Walter Roberson
Walter Roberson il 19 Dic 2021
You have two choices:
  1. You can take all of that code and store it in a file that is not named UcSayininMinimumunuBul1.m -- OR
  2. You can take the first four lines of that code and store it in a file that is not named UcSayininMinimumunuBul1.m and then store the function line downwards into file UcSayininMinimumunuBul1.m
When you have a function defined in a file, then the function name must be different than the file name except for the case where the first executable statement in the file is the function definition for a function that is the same as the file name.

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by