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 3337404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:14:56+00:00 2026-05-18T00:14:56+00:00

I have a ton of data that needs to be processed from lab work.

  • 0

I have a ton of data that needs to be processed from lab work. I have a ton of .mat files that contain a signal matrix of dimensions 7 x w. I need to resize the matrix to 7 x N and w is larger and smaller than N to make the rest of the analysis easier (don’t care about data past N). I have the psuedocode of how I want this to work but don’t know how to implement it. Any help would be great thanks!

Folder structure of all my data:

Main folder

Alpha 1
    1111.mat
    1321.mat
Alpha 2
    1010.mat
    1234.mat
    1109.mat
    933.mat
Alpha 3
    1223.mat

etc.

Psudeocode:

    Master_matrix = []
    For all n *.mat
        Load n'th *.mat from alpha 1
        If w > N
            Resize matrix down to N
        Else
            Zero pad to N
        End if
    Master_matrix = master_matrix .+ new resized matrix
    End for

rest of my code...
  • 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-05-18T00:14:57+00:00Added an answer on May 18, 2026 at 12:14 am

    First you need to generate the file list. I have my own function for that, but there is, for example, GETFILELIST or the excellent interactive UIPICKFILES to generate the list of files.

    Once you have the file list (I’ll assume it’s a cell array containing the filenames), you can do the following:

    nFiles = length(fileList);
    Master_matrix = zeros(7,N);
    
    for iFile = 1:nFiles
        %# if all files contain a variable of the same name, 
        %# you can simplify the loading by not assigning an output
        %# in the load command, and call the file by
        %# its variable name (i.e. replace 'loadedData')
        tmp = load(fileList{iFile});
        fn = fieldnames(tmp);
        loadedData = tmp.(fn{1});
    
        %# find size 
        w = size(loadedData,2);
    
        if w>=N
           Master_matrix = Master_matrix + loadedData(:,1:N);
        else
           %# only adding to the first few columns is the same as zero-padding
           Master_matrix(:,1:w) = Master_matrix(:,1:w) = loadedData;
        end
    end
    

    Note: In case you don’t actually want to add up the data, but simply store it in the master array, you can make Master_matrix into a 7-by-N-by-nFiles array, where the nth plane of Master_matrix is the content of the nth file. In this case, you’d initialize Master_matrix as

    Master_matrix = zeros(7,N,nFiles);
    

    and you’d write the if-clause as

        if w>=N
           Master_matrix(:,:,iFile) = Master_matrix(:,:,iFile) + loadedData(:,1:N);
        else
           %# only adding to the first few columns is the same as zero-padding
           Master_matrix(:,1:w,iFile) = Master_matrix(:,1:w,iFile) = loadedData;
        end
    

    Also note that you might want to initialize Master_matrix as NaN instead of zeros, so that the zeros don’t affect subsequent statistics (if that’s what you want to do with the data).

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

Sidebar

Related Questions

I have a nightly SSIS process that exports a TON of data from an
Hello I have a WinForm app that generates a ton of data. Currently I
I have just started work on asmall program that sends text over net (TON)
I have a program that has a ton of sensors producing data at a
I have a ton of data in a sql database which I would like
I have a ton of tables that vary in columns by a small amount.
I have a ton of new files to commit. Clicking each one in git
I have a script that uses a ton of redirects. About half way through
I have several laptops in the field that need to daily get information from
I have a SQL Server that holds a lot of data. An application, running

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.