AssetPaths
4 次查看(过去 30 天)
显示 更早的评论
Hello everybody. I am really desperate because I do not succeed in simulating asset paths by monte carlo simulation. Somehow, everytime I am typing in the one of the following commands:
function SPaths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl)
or
function SPaths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl) or
paths=AssetPaths(...)
I get the following message:
??? function SPaths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl) | Error: Function definitions are not permitted in this context.
Can someone please help me? Maybe I am missing the AssetPaths.m file?
Thanks for every answer
Kind regards dominic
0 个评论
回答(4 个)
Oleg Komarov
2011-6-22
You can declare a function only in a separate m. file and only as the very first line. So for example the following script will give the same error:
a = 10
function out = hi(a)
end
2 个评论
lavistacrunchy
2011-6-22
3 个评论
Walter Roberson
2011-6-22
Correct, you cannot enter function definitions at the command window or script file. You must put them in to a function .m file.
Walter Roberson
2011-6-22
At the command window,
edit AssetPaths
and paste in the code and save the file as AssetPaths.m
Angus
2011-6-22
You need to put the function AssetPath in a separate m-file that is named the same as the function.
eg: file 1: AssetPaths.m
function results = AssetPaths( ... )
statements
end
now you can invoke a call to AssetPaths on the command line like
>> paths = AssetPaths( ... input variables)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specialized Power Systems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!