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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:59:41+00:00 2026-06-12T09:59:41+00:00

I have loaded a set of 50 files into matlab workspace. (from data1 to

  • 0

I have loaded a set of 50 files into matlab workspace. (from data1 to data50).
The size of each one is 721*176. I want to extract only the first 144 lines of each data and store it in another one.

For example:

newData1 = data1(1:144,:);

My question is: How can I do this using a loop to process all data at once?

  • 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-12T09:59:43+00:00Added an answer on June 12, 2026 at 9:59 am

    That depends on how you store the data.

    The best way in your case would be 3D array:

    First, allocate the array (As @HighPerformanceMark points out correctly):

    data = zeroes(721,176,50);
    

    Then, populate it with values:

    data(:,:,1)  =  read('firstFile.bmp');
    data(:,:,2)  =  read('secondFile.bmp');
    ...
    
    data(:,:,50) = ...
    

    In that case, just use the following selection:

    data(1:144,:,:)
    

    Another plausible way to store the data is cell array. It is useful since 3D array cannot handle different size matrixes.

     data{1} = read('firstFile.bmp');
     data{2} = read('secondFile.bmp');
     ...
    

    In this case, use cellfun :

     selection = cellfun(@(x) {x(1:144,:)}, data);
    

    If you still insist on storing the data in separate variables rather than in an array, you can use eval. That is the least recommended way.

     for i=1:50
        eval(' selection{i} = data%d',i)
     end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have five text files that need to be loaded into memory. I set
I have mistakenly loaded duplicate files into a database table (IBM DB2 v9.7). I
I have two files which I loaded into lists. The content of the first
I have loaded my database with one table under Data Connections in the Server
I have loaded an byte array image from a web service to my asp.net
I have 2 sections within a table view and I have loaded one section
I have parent child data in excel which gets loaded into a 3rd party
I currently have a set of media files in the raw folder of the
I have a package that imports 7 csv files and loads them into 7
I have 3 php files. The first (connexion.php) one contains a function I use

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.