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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:58:50+00:00 2026-05-26T20:58:50+00:00

I am trying to understand a little bit more about Matlab classes and their

  • 0

I am trying to understand a little bit more about Matlab classes and their properties. Here is a test class I have created:

classdef Test    
    properties
         % Properties of the network type
        some_var
    end

    methods
         function N = Test()
         end

        function change_var( N, val )
             N.some_var=val;
        end
    end
end

Now, I create an instance of this class, and call “change_var()”…

>> a=Test;
>> a.change_var(2);
>> a.some_var

ans =

     []

Why has the property “some_var” not taken on the value “val” in the assignment?

  • 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-26T20:58:50+00:00Added an answer on May 26, 2026 at 8:58 pm

    The Test class has been defined as a value-class as opposed to a handle class. Effectively, when you call a.change_var, a is passed in by-value. To store the change to the some_var property do this:

    >> a = Test;
    >> a = a.change_var(2);
    

    The alternative is to make Test a handle class in which case the example in your question would work as you expected. To do this, inherit from the handle class by changing the first line of your class definition to this:

    classdef Test < handle
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bit flags are a little difficult to understand :) I know about this and
So this problem is a little bit complicated to understand what I'm trying to
I'm trying to understand ReST and XML a little more - A third party
I have this little bit of code: using System; using System.Web.Mvc; public class SecureFilter
been fooling around with YQL trying to understand it a little better. I've managed
I am trying to understand Http/Https a little better and possibly what headers I'm
I'm going a little nuts trying to understand the doc on impersonation and delegation
Trying to understand Ruby a bit better, I ran into this code surfing the
Trying to understand something. I created a d:\svn\repository on my server. I committed folders
Just trying to understand that - I have never used it before. How 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.