Subscripted assignment dimension mismatch.
1 回表示 (過去 30 日間)
古いコメントを表示
Hi all,
every time I run this function I get the following error message:
Subscripted assignment dimension mismatch.
Error in volas (line 12)
LMMVol(i,j) = RebonatoFormula(point(4), point(5), point(6),
point(7), psi, point(1:3), maturities, rates, i, i+j)
%tenorDate+tenorDate
function [sse] = volas(point, tenorDate, maturities, rates, maturity, marketData) %point=[beta(1) beta(2) beta(3) a b c d]
LMMVol=zeros(tenorDate-1);
alph=[point(4) point(5) point(6) point(7)];
psi = CoTerminalVolaCallibration(alph, point(1:3), maturities, rates, maturity, tenorDate, tenorDate+tenorDate, marketData);
for i=1:tenorDate-1
for j=1:tenorDate-i
%RebonatoFormula
LMMVol(i,j) = RebonatoFormula(point(4), point(5), point(6), point(7), psi, point(1:3), maturities, rates, i, i+j) %tenorDate+tenorDate
CompData(i,j) = marketData(i,j)
end
end
errors = LMMVol - CompData;
sse = sum(sum(errors .^ 2));
end
when i take away (i,j) from LMMVol in line 12, the code works but instead of the needed LMMVol-Matrix with dimension tenorLength-1 (or 10), I only get a scalar.
Does anyone know how I will get a matrix as a result?
Thanks a lot.
1 件のコメント
the cyclist
2013 年 8 月 20 日
Can you supply examples of the input parameters, so that you have self-contained code that we can actually run and show the error?
回答 (2 件)
Iain
2013 年 8 月 20 日
The error is due to the fact that the RebonatoFormula function does not always output scalar values.
You need to determine exactly what it outputs, and handle that instead of assuming that it just outputs a scalar value.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Feature Calibration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!