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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:34:35+00:00 2026-05-29T11:34:35+00:00

My day to day work flow is something like this: acquire raw data (~50GB)

  • 0

My day to day work flow is something like this:

  • acquire raw data (~50GB)
  • parse raw data timing-information and build raw data structure (struct / object) from timing-information (what event occurred when, in which order, in what file, what other events occurred at the same time, etc …)
  • load only the necessary parts of raw data into struct / object as selected from previous timing information (basically this is a way to sub-select data)
  • for each raw data chunk, calculate / extract certain metrics like RMS of signal, events where data > threshold, d’ / z-score, and save them with struct / object
  • given the the previously calculated metrics, load some raw-data of same time episodes from different data channel and compare certain things, etc …
  • visualize results x, y, z

I have two ways of dealing with this kind of data / workflow:

  1. use struct()
  2. use objects

There are certain advantages / disadvantages to both cases:

  1. struct:

    • can add properties / fields on the fly
    • have to check for state of struct every single time that I pass a struct to a function
    • keep re-writing certain functions because every time that I change the struct slightly I a) tend to forget that a function already exists for it or b) I write a new version that handles a special case of the struct state.
  2. objects:

    • using ‘get.property()’ methods, I can check the state of a property before it get’s accessed inside a function / method -> allows to do data consistency checks.
    • I always know which methods work with my object, since they are part of the object definition.
    • need to clear classes every time I add a new property or method – very annoying!

Now my question is: how do other people deal with this kind of situation? how do you organize your data? in structs? in objects? how do you handle state checks? is there a way to do ‘stateless’ programming in matlab?

  • 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-29T11:34:36+00:00Added an answer on May 29, 2026 at 11:34 am

    I like to use objects. You don’t need to call clear classes on every change. It is enough to delete all instances of the “old” object.

    Two very powerful additions I inherit often are handle and dynamicprops.

    1. Handle makes the object behave as handle. Very nice to come around matlabs copy-on-change behavior.
    2. Dynamic props – to do some meta programming.

    About the consistency checks – why no do them when you use set.property?


    Edit 1:

    a simplified class that uses the database:

    classdef measurement
       class
       id
    properties (SetAccess = private)
    
    end
    methods
    function obj = measurement(varargin)
      obj.id = varargin{1};
    end
    
        function cs = get.class(obj)
           if isempty(obj.id)
                        cs = '';
                        return
           end
           mc = mydb.local; % use some tricks here to keep the connection open
             tmp = mym(mc,...
                        'SELECT class FROM measurements WHERE id = {Si}'...
                        ,obj.id);
             cs = tmp{1};
         end
    end
    

    Edit 2: Example for Event – Observer

    classdef ObservableClass < handle
    
        properties 
            ListObservers=[]
            data
        end
    
        methods
            function obj = ObservableClass(varargin)
                obj.data = rand(100,2);
            end
    
            function addObserver(obj,observer)
                obj.ListObservers = [obj.ListObservers,observer];
            end
    
            function fireUpdate(obj)
                for i=1:numel(obj.ListObservers)
                    obj.ListObservers(i).update();
                end
            end
    
            function set.data(obj,newData)
                obj.data = newData;
                obj.fireUpdate;
            end
        end
    end
    

    and a listener:

     classdef ObservingPlot
        properties
            fig
            observedClass
        end
    
        methods
            function obj = ObservingPlot(varargin)
                obj.observedClass = varargin{1};
                obj.createPlot;
                obj.observedClass.addObserver(obj);
            end
    
            function createPlot(obj)
                obj.fig=figure;
                plot(obj.observedClass.data);
            end
    
            function update(obj)
                gcf(obj.fig)
                clf
                plot(obj.observedClass.data);
            end
        end
    
    end
    

    The example:

    a = ObservableClass()
    b = ObservingPlot(a)
    

    you can then observe when you do a: a.data=rand(100,3) – the plot will change immediatly.


    Edit 3: a simple saving class

    classdef SavingClass < handle
    
        properties 
            saveName
            data
        end
    
        methods
            function set.data(obj,input)
                if isempty(obj.saveName)
                    obj.saveName = [tempname '.mat'];
                end
                save(obj.saveName,'input')
            end
    
            function out = get.data(obj)            
                    out = [];
                   if exist(obj.saveName,'file')                   
                       tmp = load(obj.saveName);
                       out = tmp.input;
                   end
            end
        end
    
    end
    

    Example:

    a = SavingClass;
    b=rand(1000,1000);
    a.data = b;
    

    look at `whos’:

    Name         Size                Bytes  Class          Attributes
    
      a            1x1                    60  SavingClass              
      ans          1x5                    10  char                     
      b         1000x1000            8000000  double          
    

    although you can do calculations like d = a.data-b – a takes just 60 bytes in memory – as opposed to the ~8 MB of b.


    Edit 4: trick for often changing functions. When you put the logic in external commands matlab will not complain when you change the function definition there.

    classdef MyOftenEditedClass < handle
    
        properties
            a
        end
    
        methods
            function set.a(obj,val)
                mySetFunctionA(obj,val)
            end
    
            function out=get.a(obj)
                out = myGetFunctionA(obj);
            end
        end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my day-to-day work, I often find myself writing classes like in this simplified
We were discussing this the other day at work and I wish there was
I'm currently using Toad for my day-to-day work on our databases (queries, updates, small
I work with Visual Studio in my day to day job and I love
G'day! I have one million different words which I'd like to query for in
My day job includes working to develop a Pascal-like compiler. I've been working all
This is what I'd like my workflow to look like at a conceptual level:
I am just trying to work on a new featureA but would like to
I’m about to write a workflow in CRM that calls itself every day. This
I have a local branch for day-to-day dev work in git. My workflow is:

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.