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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:10:11+00:00 2026-05-25T17:10:11+00:00

Hello i need you help to append all the data i read from many

  • 0

Hello i need you help to append all the data i read from many files into a matrix. I have made the following script

path='C:\Users\Kostas\Documents\MATLAB\';
filefolder=strcat(path,'MSL*.txt');
files=dir(filefolder);
k=0;
for i=1:length(files)
    filename=strcat(path,files(i).name);    
    %load the filename and create vectors of height (Z),
    %lat and lon
    newData=importdata(filename,'\t', 1);
    vars = fieldnames(newData);
for j = 1:length(vars)
    assignin('base', vars{j}, newData.(vars{j}));
end 
    timeas=data(:,1);
    lat=data(:,2);
    lon=data(:,3);
    Z=data(:,4);
  %  daten=(timeas/24)+doy;
   k=k+1; 
%append data to matrix Teff_series
    Teff_series(k,:)= [timeas lat lon Z];
end

the error message i get when i run this script is

??? Subscripted assignment dimension mismatch.

Error in ==> te at 31
    Teff_series(k,:)= [lat lon Z];

Thanks in advance

  • 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-25T17:10:12+00:00Added an answer on May 25, 2026 at 5:10 pm

    Let me give an example:

    %# get the list of files
    fpath = 'C:\Users\Amro\Desktop\';
    files = dir( fullfile(fpath,'file*.dat') );
    files = strcat(fpath,{files.name}');
    
    %# read data from all files and store in cell array
    Teff_series = cell(numel(files),1);
    for i=1:numel(files)
        newData = importdata(files{i}, '\t', 1);
        Teff_series{i} = newData.data;
    end
    
    %# combine all into a matrix
    data = vertcat(Teff_series{:});
    colNames = newData.colheaders;
    
    %# extract columns as vectors
    t = data(:,1);
    lat = data(:,2);
    lon = data(:,3);
    Z = data(:,4);
    

    If I use these sample data files:

    file1.dat

    t   lat lon Z
    1   2   3   4
    2   3   4   5
    4   5   6   6
    

    file2.dat

    t   lat lon Z
    4   5   6   6
    2   3   4   5
    1   2   3   4
    

    I get the following results:

    >> colNames
    colNames = 
        't'    'lat'    'lon'    'Z'
    
    >> data
    data =
         1     2     3     4
         2     3     4     5
         4     5     6     6
        40    50    60    60
        20    30    40    50
        10    20    30    40
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I need help with displaying data from 2 table. So i Have 2
I need to convert all of the following forms into .NET Uri object: hello.world
hello all i really need your help its my final project in university i
All, Need some help here. I am from a purely Java background and don't
Hello stack overflow I need help with this problem. Ok, I have a flat
Hello I need to retrieve data from database via an ajax call. I am
Hello I need to have multiple language support of my django admin application.I can
Hello friends i need a book/ tutorials for rails without using scoffold. All the
string = 'Hello 1234_ world 4567_ trap 456'; I need to capture all digits
Hello I need help with Regular Expression, I want to match each section (number

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.