Error: Function definitions are not permitted in this context
2 次查看(过去 30 天)
显示 更早的评论
function s = myode_detuning(t, G, omega_e,omega_c, Omega, gamma, topt, tau_opt, tspan, gammafunc)
gammafunc = interp1(tspan,gammafunc,t); % Interpolate the data set (ts,gammafunc) at time t
s = [G(2) ; -omega_e^2 * G(1) + Omega^2 * G(3) - gammafunc * G(2) + sin(omega_c*t)*exp(-4*log(2)*(t-topt)^2/tau_opt^2); G(4) ; -omega_c^2 * G(3) + Omega^2 * G(1) - gamma * G(4)] ;
I run the code above on MATLAB R2016b to define function that's used in another MATLAB script (separate file).
tspan is defined in that another file.
However, I get errors below.
{Error: Function definitions are not permitted in this context.
}
{Undefined function or variable 'tspan'.
}
{Undefined function or variable 'G'.
}
When I run this code using MATLAB R2019a it works fine.
What do I need to fix in order to run this in R2016b?
The code above is saved in a (.m) file.
4 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!