Info

此问题已关闭。 请重新打开它进行编辑或回答。

Looping Over Matrix[29921x26] in to Find 20 Assets with Multiple Occurences

1 次查看(过去 30 天)
Hi, I conducted a few searches in order to find the solution to this problem, but none were relevent. I have a matrix(29921,26] containing certain metrics. I am searching by assets and when the specific asset is found putting it into a seperate array. But, the problem is the loops is going through all 29,921 rows but only putting the first occurence into my "metrics" matrix.
The specific assets could have one or many more occurences. This is a test file because my actual code will be run on a longleaf server and will go through millions of rows. The twenty assets were randomly generated. But they occur more than twenty times. I think 't understand why my code is only taking the first occurence, but I don't really know the most effecient way for it to collect all occurences of each asset. Please let me know if you have any solutions and I will be including my code and excel files. Thanks for the help!
%% Pull in Data
file = 'test.xlsx';
warning('OFF', 'MATLAB:table:ModifiedAndSavedVarnames');%b/c the warning was killing my job in longleaf...
dataMetrics = readtable(file,'ReadVariableNames',true);
%% Pull in Assets and Randomize
dataTable = readtable('assets.xlsx');
dataAssets = (table2cell(dataTable(:,1))); %ticker, security name, exchange
randNum = randperm(2645,20)';
%20size(rand1(:,1)
for i=1:20 %3 horizons to loop through...
rand(:,:) = dataAssets(randNum,:);
end
%% Pull Data Based On Assets
dataMetrics = table2cell(dataMetrics);
lengthData = length(dataMetrics);
for j=1:20 %
for i=1:lengthData %go through all some million rows...
if strcmp(rand(j,1),dataMetrics(i,3)) %3orSymbol
metrics(j,:) = dataMetrics(i,:); %then put in array...
end
end
end

回答(1 个)

Mason Eggers
Mason Eggers 2019-4-29
Hello James,
Unfortunately I am not equip to answer your question sufficiently. However, I do hope someone offers you a solution very soon.
Best of luck with your ventures,
M.E.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by