How to fix 'Undefined function or variable 'temp' in ode45'.
显示 更早的评论
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.

采纳的回答
更多回答(1 个)
Walter Roberson
2017-2-23
0 个投票
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
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!