如何排序表到五子集?

1视图(30天)
卢卡
卢卡 2021年4月25日
评论道: 卢卡2021年4月25日
你好,
我有表与股票。现在我想根据它们的大小成子集。我的目标是创建5子集根据他们的大小,与每个人都持有20%的股票。Unfortunatley我不知道如何去做。市值的大小。的数据集的问题。
ID是代表不同的股票
年是oberved年(1962 - 2016)
sumMC每年每个股票的市值。
有人知道怎么做吗?
提前谢谢你
4评论
卢卡
卢卡 2021年4月25日
遗憾我没有得到anround测试它在我回答他的问题。它的工作原理非常非常感谢。

登录置评。

接受的答案

图像分析
图像分析 2021年4月25日
只使用和线性索引
sortedCaps =排序(成分股市值,“提升”);
stocksPerGroup =长度(sortedCaps) / 5;
%提取股票进组# 1。
firstIndex = 1;
lastIndex =圆(stocksPerGroup);
group1 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 2。
firstIndex = lastIndex + 1;
lastIndex =圆(2 * stocksPerGroup);
group2 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 3。
firstIndex = lastIndex + 1;
lastIndex =圆(3 * stocksPerGroup);
group3 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 4。
firstIndex = lastIndex + 1;
lastIndex =圆(4 * stocksPerGroup);
group4 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 5。
firstIndex = lastIndex + 1;
lastIndex =长度(sortedCaps);
group5 = sortedCaps (firstIndex: lastIndex);

更多的答案(0)

类别

找到更多的在发动机和汽车帮助中心文件交换

下载188bet金宝搏


释放

R2021a

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!