Call function written in the same script using F9

4 次查看(过去 30 天)
Hello,
let assume this simple code with a custom routine at the end of the code:
a = 0:0.01:100;
b = sin(0:0.01:100);
RMSE_results = Routine_RMSE(a, b);
function [RMSE]=Routine_RMSE(y, yhat)
RMSE = sqrt(mean((y - yhat).^2)); % Root Mean Squared Error
end
If I run it using the RUN button, it works properly.
If I try to run it line by line executing it using F9 the function into the code appears as "undefined", however if I define the routine into an external file, then it works. The function is working also if I execute the entire "section", but is not recognized using F9.
How can call the function written in the same code using F9 ?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by