Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9273449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:07:10+00:00 2026-06-18T16:07:10+00:00

I have four data sets (please bear with me here): 1st Table: List of

  • 0

I have four data sets (please bear with me here):

  • 1st Table: List of 10 tickers (stock symbols) in one column in txt format in matlab.
  • 2nd table: dates in numerical format in one column (10 days in double format).
  • 3rd table: I have 10*10 data set of random numbers (assume 0-1 for simplicity). (Earnings Per Share growth EPS for example)–so I want high EPS growth in my ranking for portfolio construction.
  • 4th table: I have another 10*10 data set of random numbers (assume 0-1 for simplicity). (Price to earnings ratios for example daily).-so I want low P/E ratio in my ranking for portfolio construction.

NOW: I want to rank portfolio of stocks each day made up of 3 stocks (largest values) from table one for a particular day and bottom three stocks from table 2 (smallest values). The output must be list of tickers for each day (3 in this case) based on combined ranking of the two factors (table 3 & 4 as described).

Any ideas? In short I need to end up with a top bucket with three tickers…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:07:12+00:00Added an answer on June 18, 2026 at 4:07 pm

    It is not entirely clear from the post what you are trying to achieve. Here is a take based on guessing, with various options.

    Your first two “tables” store symbols for stocks and days (irrelevant for ranking). Your third and fourth are scores arranged in a stock x day manner. Let’s assume stocks vertical, days horizontal and stocks symbolized with a value in [1:10].

    N = 10; % num of stocks
    M = 10; % num of days   
    T3 = rand(N,M); % table 3 stocks x days
    T4 = rand(N,M); % table 4 stocks x days
    

    Sort the score tables in ascending and descending order (to get upper and lower scores per day, i.e. per column):

    [Sl,L] = sort(T3, 'descend'); 
    [Ss,S] = sort(T4, 'ascend');
    

    Keep three largest and smallest:

    largest = L(1:3,:);  % bucket of 3 largest per day
    smallest = S(1:3,:); % bucket of 3 smallest per day
    

    IF you need the ones in both (0 is nan):

    % Inter-section of both buckets
    indexI = zeros(3,M);
    for i=1:M
        z = largest(ismember(largest(:,i),smallest(:,i)));
        if ~isempty(z)
            indexI(1:length(z),i) = z;
        end
    end
    

    IF you need the ones in either one (0 is nan):

    % Union of both buckets
    indexU = zeros(6,M);
    for i=1:M
        z = unique([largest(:,i),smallest(:,i)]);
        indexU(1:length(z),i) = z;
    end
    

    IF you need a ranking of scores/stocks from the set of largest_of_3 and smallest_of_4:

    scoreAll = [Sl(1:3,:); Ss(1:3,:)];
    indexAll = [largest;smallest];
    
    [~,indexSort] = sort(scoreAll,'descend');
    for i=1:M
        indexBest(:,i) = indexAll(indexSort(1:3,i),i);
    end
    

    UPDATE

    To get a weighted ranking of the final scores, define the weight vector (1 x scores) and use one of the two options below, before sorting scoreAllW instead of scoreAll:

    w = [0.3 ;0.3; 0.3; 0.7; 0.7; 0.7];
    scoreAllW = scoreAll.*repmat(w,1,10);    % Option 1
    scoreAllW = bsxfun(@times, scoreAll, w); % Option 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four HTML tables and have to compare data from one table with
I have four level data structure defined like this: Dictionary<Type1, Dictionary<Type2, Dictionary<Type3, List<Type4>>>> The
I have four tabs which the first one inserts data on the database, the
I am retrieving whole data from database in list?Now i have four class like:
The main concept goes like this. I have four listviews with its own data
I have a page that needs to combine data from four different webrequests into
I have a data frame of daily data: df with four columns: Date, A,
I have a Database named CarsType.accdb there are four fields in the data base
I have four tables. Three of them are tables with one key and they
I have four threads in a C++/CLI GUI I'm developing: Collects raw data The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.