Error with variable definition
Mostra commenti meno recenti
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 Commento
KSSV
il 1 Ott 2020
What error it throws?
Risposte (1)
KSSV
il 1 Ott 2020
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)
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!