Matlab function undefined variable error
4 次查看(过去 30 天)
显示 更早的评论
Hi i have used matlab function in simulation and the function equation is
function y = ks(u)
y = u*lo;
end
I have difined lo in m.file at the same name of the function "ks"
lo=5;
evry time i eun the simulation i got error "Undefined function or variable 'lo'."
0 个评论
采纳的回答
Ameer Hamza
2020-10-2
Define lo inside the function
function y = ks(u)
lo = 5;
y = u*lo;
end
3 个评论
Ameer Hamza
2020-10-2
I got the impression that OP is referring to Simulink's MATLAB function block. There are ways to share data from the base workspace, but the easiest is just to define it inside the function block.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!