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

  • SEARCH
  • Home
  • 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 8576699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:59:03+00:00 2026-06-11T19:59:03+00:00

I would like to have a program that makes the following actions: Read several

  • 0

I would like to have a program that makes the following actions:

  • Read several matrices having the same size (1126×1440 double)

  • Select the most occuring value in each cell (same i,j of the matrices)

  • write this value in an output matrix having the same size 1126×1440 in the corresponding i,j position, so that this output matrix will have in each cell the most occurent value from the same position of all the input matrices.

  • 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-11T19:59:04+00:00Added an answer on June 11, 2026 at 7:59 pm

    Here is the code you need. I have introduced a number of constants:

    nmatrices - number of matrices
    n, m      - dimensions of a single matrix
    maxval    - maximum value of an entry (99)
    

    I first generate example matrices with rand. Matrices are changed to vectors and concatenated in the CC matrix. Hence, the dimensions of CC are [m*n, nmatrices]. Every row of CC holds individual (i,j) values for all matrices – those you want to analyze.

    CC = [];
    % concatenate all matrices into CC
    for i=1:nmatrices
        % generate some example matrices
        % A = round(rand(m, n)*maxval);
        A = eval(['neurone' num2str(i)]);
        % flatten matrix to a vector, concatenate vectors
        CC = [CC A(:)];
    end
    

    Now we do the real work. I have to transpose CC, because matlab works on column-based matrices, so I want to analyze individual columns of CC, not rows. Next, using histc I find the most frequently occuring values in every column of CC, i.e. in (i,j) entries of all matrices. histc counts the values that fall into given bins (in your case – 1:maxval) in every column of CC.

    % CC is of dimension [nmatrices, m*n]
    % transpose it for better histc and sort performance
    CC = CC';
    % count values from 1 to maxval in every column of CC
    counts = histc(CC, 1:maxval);
    

    counts have dimensions [maxval, m*n] – for every (i,j) of your original matrices you know the number of times a given value from 1:maxval is represented. The last thing to do now is to sort the counts and find out, which is the most frequently occuring one. I do not need the sorted counts, I need the permutation that will tell me, which entry from counts has the highest value. That is exactly what you want to find out.

    % sort the counts. Last row of the permutation will tell us, 
    % which entry is most frequently found in columns of CC
    [~,perm] = sort(counts);
    
    % the result is a reshaped last row of the permutation
    B = reshape(perm(end,:)', m, n);
    

    B is what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that reads data from a file line-by-line. I would like
I have a program that generates/'rolls' two dice. I would like to output these
I have a java program that is running in the background(Windows). I would like
I have completed my program and would like to send that program in its
I have a Datatable in my C# program that I would like to INSERT
So I have a program that runs something like the following public class SHandler
I have a C++ program that compiles to 9.5k. I would like it to
I would like to program the following situation: I have 2 different ListViews in
I have a program which I would like to run every X min the
I have a program which takes a long time to complete. I would like

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.