How to fix 'Undefined function or variable 'temp' in ode45'.
Show older comments
My code below gives me the error
Undefined function or variable 'temp'.
when using the command
[t,u] = ode45(@temp,[0,20],[20]);
which I intent to create a graph with. As a note, I used 'global' to define and then set the values of my constants.
If necessary, the purpose of this code is to create a graph for a CPU temperature based on data from a lab.

Accepted Answer
More Answers (1)
Walter Roberson
on 23 Feb 2017
0 votes
You have not stored the code in temp.m or temp.m is not on your path.
Note: global variables are the slowest kind of variables. You should avoid them. See https://www.mathworks.com/help/matlab/math/parameterizing-functions.html
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!