How can I fix this error?

13 ビュー (過去 30 日間)
Razvan Tataru
Razvan Tataru 2018 年 5 月 28 日
コメント済み: Razvan Tataru 2018 年 5 月 28 日
Hello everyone
function [cost] = costf(x)
global data; global finalcost;
% Compute individual differences
% Sum of squares performed by Matlab's lsqnonlin
for i=1:length(data)
cost(i)= data(i, 5) - call_heston_cf(data(i, 1),x(1), x(2), (x(5)+x(3)^2)/(2*x(2)), x(3), data(i, 4), x(4), data(i, 2),
data(i, 3));
end
% Show final cost
finalcost =sum(cost)^2
end
I have this code for calibration of Heston price and I get this error (for line 6 and 7):
Error: File: costf.m Line: 6 Column: 121
Expression or statement is incorrect--possibly unbalanced (, {, or [.
and also it says Parse error at <EOL>: usage might be invalid MATLAB syntax for line 6
and
Parse error at ')':usage might be invalid MATLAB syntax for line 7.
I'm really new to MATLAB and I really need your help.
Thank you for your time!

採用された回答

Walter Roberson
Walter Roberson 2018 年 5 月 28 日
You split the code over multiple lines without using ... to indicate that the line was being continued. You should put all of that code of line 6 onto one line.
cost(i)= data(i, 5) - call_heston_cf(data(i, 1),x(1), x(2), (x(5)+x(3)^2)/(2*x(2)), x(3), data(i, 4), x(4), data(i, 2), data(i, 3));
  1 件のコメント
Razvan Tataru
Razvan Tataru 2018 年 5 月 28 日
Thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTransfer Function Models についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by