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!