Function command y = f(x)
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Igor
am 15 Okt. 2014
Beantwortet: Star Strider
am 15 Okt. 2014
So, here's a screenshot of my problem.
The upper part is the text from a Matlab Essentials book, and the lower part is where I try the example given in the book.
Why is it giving me an error? What am I missing here?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 15 Okt. 2014
unction definitions of that sort are not permitted in regular script files, only within other function files. You have to create a new script with:
function y = f(x)
as the first line, then save the file as f.m. It should work then.
To call it from your main script:
x = 10; % Random choice
y = f(x)
0 Kommentare
Weitere Antworten (1)
Orion
am 15 Okt. 2014
because you're trying to declare a function in the command window, which is impossible.
a function can only be declared in a Mfile.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Adding custom doc finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!