I'm trying to find the s vector that will gave me the value of ValorMercado=ValorMercadonovo.
This is my code:
Price=[99.23;100.05;91;107.71;104.1];
cashflows=[3441 3441 301720.5;68750 1068750 0;170040 13085020 0;229350 229350 5729350;34194000 0 0];
NominalValue=[300000;1000000;13000000;5500000;32800000];
eiopa=[-0.00302;-0.00261;-0.00208];
[c3,r3]=size(Price);
[c4,r4]=size(cashflows);
ValorMercado(1:c3,1)=Price(1:c3,1).* NominalValue(1:c3,1) ./100;
s=transpose(sym ('s',[1 c3]));
S=sym(zeros(c3,1));
for i=1:c3
ValorMercadonovo(i,1)(S)=0;
for j=1:r4
ValorMercadonovo(i,1)(S)=(ValorMercadonovo(i,1)/((1+eiopa(j,1)+S(i,1))^j))+(cashflows(i,j)/((1+eiopa(j,1)+S(i,1))^j));
end
end
for i=1:c3
x(i,1)=fzero(@(S)ValorMercado(i,1) - ValorMercadonovo(S)(i,1),[0,1]);
end
the error is Error: ()-indexing must appear last in an index expression.. What is wrong?

댓글 수: 1

Alan Weiss
Alan Weiss 2017년 7월 14일
Please correct the error in your displayed code so that we can see what the issue might be. As Matt J said, the current question has an obvious syntax error, and we cannot proceed.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2017년 7월 14일

0 개 추천

The expression
ValorMercado(S)(i,1)
doesn't make sense. ValorMercado is a numeric vector, so can only be indexed with one pair of ()

댓글 수: 2

Mariana Ferreira
Mariana Ferreira 2017년 7월 14일
It was there by lapse. Already fixed but its not working anyway. Could you help please?
No, we need to know what the new error messages are. Also, I still see
ValorMercadonovo(i,1)(S)
What is it supposed to mean?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Optimization Toolbox에 대해 자세히 알아보기

질문:

2017년 7월 14일

댓글:

2017년 7월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by