I have a 3740x5 matrix called 'Rets'. I want to find the mean of every column vector. I tried using the function mean(Rets) and this is what I get:
mean(Rets)
ans =
1.0e-03 *
0.1591 0.2098 0.1475 -0.0623 -0.8807
I should only have 5 values in this row vector (from 0.1591 to -0.8807, as shown above), why do I have 6 values? I understand 1.0e-03 is the average of all the values in the row vector. So here is my question: How can I create a vector that only has these 5 values I need? Thanks!

2 件のコメント

John D'Errico
John D'Errico 2014 年 7 月 15 日
Look at the little * there. * means multiplication in matlab.
civs
civs 2014 年 7 月 16 日
Hi John, thanks for your answer. Please see my answer to James Tursa below.

サインインしてコメントする。

 採用された回答

James Tursa
James Tursa 2014 年 7 月 15 日
編集済み: James Tursa 2014 年 7 月 15 日

2 投票

There are five values listed. Each of the five values in the 2nd row is multiplied by the factor 1.0e-3. It is MATLAB's way of writing the following equivalent information:
0.1591e-3 0.2098e-3 0.1475e-3 -0.0623e-3 -0.8807e-3
To convince yourself of this, do the following:
size(ans)

3 件のコメント

civs
civs 2014 年 7 月 16 日
Hi James, Thank you very much for your answer. This makes perfect sense, however, I have another vector called 'Wmin', these are the asset weights of a portfolio:
>> Wmin
Wmin =
0.0211
0.2977
0.4616
0.1835
0.0361
I created the vector mean_ret_assets= mean(Rets). I tried element-wise multiplication Wmin.*mean_ret_assets and I get an error that says:
>> Wmin.*mean_ret_assets Error using .* Matrix dimensions must agree.
If the two vectors have 5 elements, why am I getting this error? I don't understand. Thanks again!
James Tursa
James Tursa 2014 年 7 月 16 日
One is a row vector and the other is a column vector. You can't element-wise multiply a 1x5 with a 5x1. To get around this, e.g., you could turn the row vector into a column vector with the (:) notation, like this:
Wmin.*mean_ret_assets(:)
civs
civs 2014 年 7 月 16 日
James, THANK YOU SOOOOO MUCH!!! It's looking good now, thank you thank you!!! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2014 年 7 月 15 日

コメント済み:

2014 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by