Error with variable definition
Afficher commentaires plus anciens
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 commentaire
KSSV
le 1 Oct 2020
What error it throws?
Réponses (1)
KSSV
le 1 Oct 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)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!