필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

PROBLEM WITH FUNCTION IF

조회 수: 1 (최근 30일)
Karim Hasouna
Karim Hasouna 2019년 10월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
for n=0.00:0.01:0.20;
factor= exp(-(n).*((1:NTcoupon)/Ncoupon));
Price = C*factor' +FV*exp(-(n)*t);
disp("the price of the coupon bond is:" +Price )
plot(Price)
end
I don't understand why the output is not a matrix with t components right priced.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 6일
You do not ask to output a matrix. You output a string to the display, and you ask to plot() something. You do not appear to have hold on in effect, so each plot() will overwrite the previous plot.
Also, your loop does not use n . It does, however, use i . It is not obvious from your code whether you assigned something to i. If you did not, then i will have its default value of sqrt(-1) . If you intend it to be sqrt(-1) then it would be clearer if you code 1i instead of i .
I recommend that you read

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by