Attempt to execute SCRIPT ... as a function:
Ältere Kommentare anzeigen
I am very new to MatLab and this is probably a really easy fix but functions are giving me a headache.
global fakt1 fakt2 fakt3
fakt1=2; fakt2=3; fakt3=4;
testfunktion1(10)
function erg=testfunktion1(x)
erg=fakt1*x^3+fakt2*x^2+fakt3*x;
end
I first named the file "testfunktion.m" but then got the Error "Local function name must be different from the script name". After changing the function name and trying to run the script I get the Error
">> testfunktion(10)
Attempt to execute SCRIPT testfunktion as a function: C:\Users\....."
Now I am kind of clueless on what to do.
2 Kommentare
Maha
am 4 Nov. 2024
Verschoben: Cris LaPierre
am 4 Nov. 2024
I am facing an error while executing my script
>> my_model_script
Attempt to execute SCRIPT xlabel as a function:
F:\MathWorks_MATLAB_R2020a_v9.8.0.1323502\toolbox\matlab\graph2d\xlabel.m
Error in my_model_script (line 12)
xlabel('Time (s)');
Don't know what happens it was smooth before. I checked over the location as well but no use
Cris LaPierre
am 4 Nov. 2024
Verschoben: Cris LaPierre
am 4 Nov. 2024
The path looks correct, and that xlabel.m file is a function. Have you by chance named your script 'xlabel'?
What is the result of the following command: which xlabel -all
Akzeptierte Antwort
Weitere Antworten (1)
Ameer Hamza
am 20 Nov. 2020
What do you mean by '10' on this line
testfunktion(10)
To call a script, you just need to type the script name
testfunktion
Or you can press the big green "Run" button.
1 Kommentar
Armin Schindler
am 21 Nov. 2020
Kategorien
Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!