Problem plotting two parametric equations

1 visualización (últimos 30 días)
Nicolas Heumann
Nicolas Heumann el 16 de Jun. de 2019
Respondida: Sulaymon Eshkabilov el 16 de Jun. de 2019
I am working on a quantitative finance problem, and I wish to plot the following functions:
and for w between 0 and 1. I have tried the following code:
w=linspace(0,1);
mu= 0.1*w+0.14*(1-w);
sigma = (0.12^2)*w.^2+0.4*0.12*0.2*2*w(1-w)+(0.2^2)*(1-w).^2;
plot(mu,sigma);
xlabel('mu'),ylabel('sigma')
title('risk vs return')
And I get the following errors:
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'.
But when I replaced the "^" for ".^", I got this error
Array indices must be positive integers or logical values.
And I don't know how to proceed. How could I fix this issue?

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 16 de Jun. de 2019
Hi,
Here is the fixed code:
w=linspace(0,1);
mu= 0.1*w+0.14*(1-w);
sigma = (0.12^2)*w.^2+0.4*0.12*0.2*2*w.*(1-w)+(0.2^2)*(1-w).^2;
plot(mu,sigma);
xlabel('mu'),ylabel('sigma')
title('risk vs return')

Más respuestas (0)

Categorías

Más información sobre Financial Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by