Writing a loop or function (simple) MATLAB -


i beginner user of matlab, please me how write code. inputs are:

port_returns - 196x1 column vector

var - scalar

variance_portfolio - scalar

   port_returns=returns*weights';     var=1.65*sqrt(variance_portfolio); 

and want write code, take port_returns values, less var value , average it.

could me that?

thank in advance!

this should trick:

sum(port_returns(port_returns<var))/length(port_returns(port_returns<var))

where

sum(port_returns(port_returns<var))

finds elements in port_returns smaller var , sums them up,

and divided number of elements smaller var:

port_returns(port_returns<var)


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -