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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:15:09+00:00 2026-06-17T16:15:09+00:00

I need to concatenate multiple files’ data into one matrix. So far, the way

  • 0

I need to concatenate multiple files’ data into one matrix.
So far, the way that I have been testing loading my data is something akin to the following:

fid = fopen('data01.txt', 'r');
raw = textscan(fid, '%d/%d/%d %d:%d:%f %f %f %f %d', 'delimiter', ',');
m = cellfun(@double, raw, 'UniformOutput', false);
value_of_interest = m{:,10}

…But the data set that I have on disk is many files and all exist within a single directory. I’d prefer to refer to a specific path for this directory, rather than placing my script there. How can I modify my script so that it loads all data for all of the files in said folder?

So far I have this:

dirname = uigetdir;
files = dir(dirname);
fileIndex = find(~[files.isdir]);

for i = 1:length(fileIndex)
    fileName = files(fileIndex(i)).name;
    fid = fopen(fileName, 'r');
    raw = textscan(fid, '%d/%d/%d %d:%d:%f %f %f %f %d', 'delimiter', ',');
    time = [m{:,4}, m{:,5}, m{:,6}];  %needs to contain a float
    converted_time = ((m{:,4} *  3600.0) + (m{:,5} * 60.0) + m{:,6}); %hh:mm:ss -> seconds
    values = power(m{:,10}, 2); 
    values(values <= thresh) = 0;
    % need to concat into the var 'values' here... also need to accumulate the time variable
end 

plot(converted_time, values);

…But I need to put the two together.

EDIT: I should mention that I may run out of memory, which is explained later in comments below to my chosen answer.

  • 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-17T16:15:10+00:00Added an answer on June 17, 2026 at 4:15 pm

    First, have another look at how you are defining the fileName of the file to be opened. Instead, you should try fileName = [dirname, '\', files(fileIndex(i)).name];, since the name field of files will not contain the full path. This will solve your problem of referencing a list of files that are not in your current path.

    Now, to avoid remembering all the data from all those files, we can do this job per file inside the loop:

    ...
        plot(converted_time, values);
        hold('on');
    end
    

    The short command hold('on');, often written simply hold on; modifies the plot axes such that subsequent data can be plotted without erasing any previous lines.

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

Sidebar

Related Questions

I have a bunch of js files that I need to concatenate in some
Assuming there are multiple data entities that need to be saved within a database
I need to write a procedure to normalize a record that have multiple tokens
I have a number of base64 strings that I need to concatenate to send
I need to concatenate some relatively large text files, and would prefer to do
I have a situation where I need to concatenate several string to form an
I need help to concatenate 2 vars into 1 var, or any other method
Need some regular expressions help. So far I have my code working to allow
I'm currently using PHP to include multiple css (or js) files into a single
Is there a way to concatenate a unknown number of querysets into a list?

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.