Subscripted assignment dimension mismatch.
1 view (last 30 days)
Show older comments
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 Comment
the cyclist
on 20 Aug 2013
Can you supply examples of the input parameters, so that you have self-contained code that we can actually run and show the error?
Answers (2)
Iain
on 20 Aug 2013
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 Comments
See Also
Categories
Find more on Feature Calibration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!