i have a problem with my code and i dont know how solve this?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
vachelard
el 5 de Abr. de 2014
Comentada: vachelard
el 6 de Abr. de 2014
I have a matrix of monthly returns I call Ynet (193.1) I'd like to build a matrix yields random I call randomR with an average yield of my one line is equal to the value of the row Ynet has.
Ynet example, if (1,1) = 0.23 I need the average randomR (1, :) is equal to 0.23.
Until then I got there, the problem comes from my values of my matrix randomR I need them to be between [-0.25, 0.25] gold mine that is not always the case. Over the size of my matrix randomR must be between 1 and 30 depending on the number of returns I want.
That is where I am:
simulation = -0.2 +0.4 * rand (193.5).;
rowsum = mean (simulation 2);
simulation bsxfun = (@ rdivide, simulation, rowsum);
for i = 1:5
randomR (:, i) = simulation (:, i) * Ynet,.
end
thank you
3 comentarios
Image Analyst
el 5 de Abr. de 2014
I've read your post 6 times and I can't understand it. Like what does this mean: "I call Ynet (193.1)" What is 193.1? That can't be part of the variable name. We don't know how many more writing errors there might be, so it's best to attach your m-file with the paper clip icon, after you've put in a comment before each line about what that line is supposed to do.
Respuesta aceptada
Más respuestas (2)
Walter Roberson
el 5 de Abr. de 2014
mean(simulation, 2)
does not calculate a row sum. You would use sum(simulation, 2) for a row sum
2 comentarios
Image Analyst
el 5 de Abr. de 2014
Like I said, I can't figure out what you want. You say " I need them (randomR) to be between [-0.25, 0.25] gold mine that is not always the case. Over the size of my matrix randomR must be between 1 and 30". So which is it ? Do you need randomR values to be between -.25 and +.25, OR between 1 and 30?
6 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!