Can anyone explain why this code works fine:
t = 1:0.001:2;
u1 = exp(0.5)*((1-exp(-0.5*t))/(1-exp(-0.5)) - 1);
u2 = log(t)/log(2);
u3 = (sqrt(t)-1)/(sqrt(2)-1);
plot(t,u1,t,u2,t,u3,'LineWidth',2)
legend('exp', 'log', 'iso-e', 'location','northwest')
xlabel('$t$','interpreter','latex')
ylabel('$\tilde{u}(t)$','interpreter','latex')
But the following code throws an error because t is an array? If this is not how you're supposed to define a variable, what is the correct way?
t = 0:200;
VaR = logninv(0.1,3,1)
f = t*logncdf(t,3,1)/0.1;
CVaR = integral(f,-inf,VaR)

1 件のコメント

KSSV
KSSV 2020 年 10 月 1 日
What error it throws?

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2020 年 10 月 1 日

0 投票

t = 0:200;
VaR = logninv(0.1,3,1)
f = t.*logncdf(t,3,1)/0.1; % < ---- element by element operation
CVaR = integral(f,-inf,VaR)

カテゴリ

ヘルプ センター および File Exchange で Mathematics についてさらに検索

製品

リリース

R2020b

質問済み:

2020 年 10 月 1 日

回答済み:

2020 年 10 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by