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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:00:19+00:00 2026-05-29T15:00:19+00:00

%example clear all a1 = struct(‘data1′,rand(12,2),’data2′,rand(12,2),’data3’,rand(12,3)); a2 = struct(‘data1′,rand(12,2),’data2′,rand(12,2),’data3’,rand(12,3)); a3 = struct(‘data1′,rand(12,2),’data2′,rand(12,2),’data3’,rand(12,3)); a4 =

  • 0

%example

clear all
a1 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
a2 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
a3 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
a4 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));

Pretend that the structures represent a time series where a1 represents the
first 5 day (for example), a2 represents day 5-10 and so on… I’m trying to
combine every fieldname in the structures so that I have one continuous series (instead of having them split into different structures. For example…

data1 = [a1.data1;a2.data1;a3.data1;a4.data1];

and then do the same for data2 and data3

What would be the best way to do this?

  • 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-29T15:00:20+00:00Added an answer on May 29, 2026 at 3:00 pm

    The best way is to define the structures as array of structures beforehand:

    a(1) = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
    a(2) = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
    a(3) = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
    a(4) = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
    

    Which allows you to get the data quite easily:

    cat(1,a.data1)
    

    But if you insist on using N structs, then try this:

    function so3
        a1 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
        a2 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
        a3 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
        a4 = struct('data1',rand(12,2),'data2',rand(12,2),'data3',rand(12,3));
    
        s{1} = struct2cell(a1);
        s{2} = struct2cell(a2);
        s{3} = struct2cell(a3);
        s{4} = struct2cell(a4);
    
        N = numel(fieldnames(a1));
        data = cell([1 N]);
        for i=1:N
            data{i} = cell2mat(cellfun(@(x){x{i}'},s));
        end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take the following example: clear all Name1 = {'Data1','Data2','Data3','Data4'}; Data = {6.2,6,3.2,8}; CombnsName =
Take the following example: clear all depth = [0,2,4,7,10,13,16,19,22,25,30,35];%depth below surface temp = 0
clear all FieldName = {'loc1','loc2','loc3','loc4'}; data = rand(8760,4); dnew = mat2cell(data,eomday(2011, (1:12))*24,size(data,2)); k =
i want to clear all values in grid children example if one of my
Sorry for the unclear title, an example will clear things up: TABLE: Scenario_victories ID
GridView CurrentGrid =Grd_UserList; Grd_UserList.Columns.Clear(); ı have got this example, ı use Columns.Clear(); fonc. with
Example: I have an class that inherits from UIImageView. An object creates an instance
The following example resembles a similar problem that I'm dealing with, although the code
I have the following example which expresses the type of problem that I'm trying
My question for today is: How can I make function that could find all

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.