Local functions are not working in MatLab R2022a
Mostra commenti meno recenti
I'm trying to write local functions in the way instructed in this video: https://www.youtube.com/watch?v=f0zKcuP3Wc0&list=PLlvaivyRxHmdTvpNBe4gKWrOBrcuxhpsl&index=48, beginning at 5:50. When running the code below, my MatLab R2022a says Unrecognized function or variable 'mymean'. What am I missing here?
x = 1:10;
n = length(x);
avg = mymean(x,n)
function a = mymean(v,n)
a = sum(v)/n;
end
6 Commenti
Steven Lord
il 9 Giu 2022
What's the name of the file in which you saved this code?
We can run your code in R2022a right here in the forum. As you can see below, it works. So, whatever the problem is, it's something in your environment specificially.
x = 1:10;
n = length(x);
avg = mymean(x,n)
function a = mymean(v,n)
a = sum(v)/n;
end
Jonne Klockars
il 9 Giu 2022
Jonne Klockars
il 9 Giu 2022
Stephen23
il 9 Giu 2022
@Jonne Klockars: how are you running the script? Please show the exact code you use to run your file.
Jonne Klockars
il 9 Giu 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Get Started with MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!