Subscripted assignment dimension mismatch.
显示 更早的评论
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
0 个投票
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.
Mario
2013-8-20
编辑:Walter Roberson
2013-8-20
类别
在 帮助中心 和 File Exchange 中查找有关 Sparse Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!