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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:31:47+00:00 2026-06-15T18:31:47+00:00

I have over a thousand matrices (6 x 2000, ASCII files, comma delimited) that

  • 0

I have over a thousand matrices (6 x 2000, ASCII files, comma delimited) that I generated from MATLAB. I want to get the last row of each matrix / text file and save them in a new matrix / text file. The text files have crazy names so when I load them I can name them whatever. Right now I would do this to achieve my goal:

% A = load('crazyname.txt');
% B = load('crazynameagain.txt');
% C = load('crazynameyetagain.txt');

A = [5 5 5; 5 5 5; 1 1 1];
B = [5 5 5; 5 5 5; 2 2 2];
C = [5 5 5; 5 5 5; 3 3 3];

D(1,:)=A(end,:);
D(2,:)=B(end,:);
D(3,:)=C(end,:);

I will create each command (e.g. load, building D step by step) in Excel by combining text cells to create a command. Is there a better way to do this? Could I load / assign the matrices with a name that would better suit them to be used in a for loop? Or is some other MATLAB command that would facilitate this?

Thanks.

  • 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-15T18:31:48+00:00Added an answer on June 15, 2026 at 6:31 pm

    Suppose, you have all the csv files in folder d:/tmp, each contains 6x2000:

    folder = 'd:/tmp';
    files = dir(fullfile(folder, '*.csv'));
    res = cell2mat(cellfun(@(x) csvread(fullfile(folder, x), 5, 0), {files.name}', 'UniformOutput', false));
    

    Note the arguments of csvread().

    Edit: if the delimiter is space ' ':

    res = cell2mat(cellfun(@(x) dlmread(fullfile(folder, x), ' ', 5, 0), {files.name}', 'UniformOutput', false));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, we have a loop that: 1.Loops over several thousand xml files. Altogether
If I'm building an application that will have over 30 models, and I want
I have taken over a project that was build from suggestions in this Dan
I have over a thousand folders, each folder contains one or more files with
We all know the effects that lots of thrown exceptions can have over the
im planning to create a movie file that might have over 16,000 frames?i know
i have taken over a database that stores fitness information and we were having
I have taken over some code from a previous developer and have come across
In my code I have a map that is used heavily, several thousand times
I have a python cgi script that runs an application via subprocess over and

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.