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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:47:30+00:00 2026-05-24T09:47:30+00:00

I am working on a statistical model of a content distribution server in MATLAB

  • 0

I am working on a statistical model of a content distribution server in MATLAB and have decided to use OO programming. This is my first foray into OO with MATLAB and I have hit a snag. I am attempting to model a download connection to the server, at the moment it is just a MATLAB timer and a boolean. When the timer expires I want to set the isActive field from true to false. So quite simple I feel but then I have been battling with this for more then a day now. Below is the code for the class so far:

    classdef dl<handle
        properties
            isActive = true
            ttl = 0
        end
        methods
            function this = startTimer(this, varargin)
                this.ttl = timer('TimerFcn', @()killConnection(this), 'StartDelay',1);     
                start(this.ttl);            
            end
        end

        methods (Access = private)
            function obj = killConnection(obj, varargin)
                obj.isActive = false;
            end        
        end
    end
  • 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-24T09:47:30+00:00Added an answer on May 24, 2026 at 9:47 am

    I solved the problem I was having, the issue was in the way the callback handler was declared. Im not sure if the precise reason but there is a better explanation here if anyone is interested, see this blog post http://syncor.blogspot.com/2011/01/matlabusing-callbacks-in-classdef.html.

    Here are the changes I made to get successful operation. Firstly i changed the callback function into the proper structure for the callback:

        function killConnection(event, string_arg, this)
    

    Then I declared the callback differently in the timer:

        this.ttl = timer('TimerFcn', {@dl.killConnection, this}, 'StartDelay',1);
    

    This worked for me. Thanks for the help it was really getting to me :P.

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

Sidebar

Related Questions

I'm working with matplotlib to build a very basic GUI around a statistical model/simulation.
I had this simple modal contact form working fine but must have broke it
Working on a project at the moment and we have to implement soft deletion
I have a regression model in which the dependent variable is continuous but ninety
I have implicitly made this a community wiki seeing that the answers can be
I have learned a Machine Learning course using Matlab as a prototyping tool. Since
In a project that I'm working on I have a decision problem and none
I have a working copy of my project, checked out using Subversion 1.5.1. When
I am wondering if anyone has any insight into this. I am thinking of
I'm working on a Dungeons and Dragons character database. I have two models, character

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.