I am getting that error explanation"function [out] = celsi2farh( x, i ) ↑ Error: Function definition not supported in this context. Create functions in code file." Could you please helpm me to get rid of this error ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function [out] = celsi2farh( x, i ) % x: temperature either celsius or fahrenheit % i: flag - 0: F, 1: C, otherwise: error
if i==0 % F -> C out = (5./9.)*(x-32.0) elseif i==1 % C -> F out = (9./5.)*x + 32.0 else error("other value") end
0 commentaires
Réponses (1)
David Fletcher
le 3 Avr 2018
Modifié(e) : David Fletcher
le 3 Avr 2018
I think recent versions of Matlab (I don't know from which version) allow a function to be put on the bottom of a script file, but generally functions need to be saved in their own file on the Matlab search path, and the file name should be the same name as the function name. Functions are then called from the command line (or from a script file) by their name.
celsi2farh(0,1)
out =
32
ans =
32
Seems to work
0 commentaires
Voir également
Catégories
En savoir plus sur File Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!