Object oriented programming in matlab

Поділитися
Вставка
  • Опубліковано 14 жов 2024

КОМЕНТАРІ • 24

  • @codethemath4759
    @codethemath4759  3 роки тому +1

    Hi Guys, if you find this content useful please leave some commnet, it helps to spread the content in YT. Your help highly important because this chanel is just starting

  • @insunghan9239
    @insunghan9239 3 роки тому

    I finally understood the concept of classdef, properties.......

    • @codethemath4759
      @codethemath4759  3 роки тому +1

      I'm glad that was helpful. In a near future I will make videos about more professional approach to the topic with python and sci-kit learn. I hope it will also be helpful for you

  • @ahmedamr5265
    @ahmedamr5265 3 роки тому +2

    Just one question: If "ThisWorker" is used to create objects of the class, what does "TheWorker" do exactly?

    • @codethemath4759
      @codethemath4759  3 роки тому +5

      Hi. thanks you for your comments. If it comes to 'the' it is a key word to indicate that you want to use a data witch are storred in this particular object of a class. I'm also quite supprised witch it, because in C++ we have only one word 'this' for bouth functions.

  • @harikrishnahariprasad2141
    @harikrishnahariprasad2141 Рік тому

    Great content! Thank you so much!

  • @PraveenKumar-hr1xv
    @PraveenKumar-hr1xv 3 роки тому

    Very useful content! Thanks!!
    Looking forward to more content on Matlab oops.

    • @codethemath4759
      @codethemath4759  3 роки тому +2

      Thanks you, I have provide another video about OOP in matlab, and I 'm going to cover more topics such as polimorfizm and abstract classes in a near future. I hope it wil also be usefull for you.

  • @luca_reali
    @luca_reali 2 роки тому

    Hey there, thanks for your video! I was wondering if you can help me out with the following error that Matlab gives me: "Dotted names can be used only within a CLASS block" referring to the function "get.last_performance". I'm totally new to this topic so I'm not really skilled in debugging, but I double checked the code with yours and it seems to be the same. Thanks in advance!
    P.S. Running on Matlab R2021a.

  • @userjdufer466
    @userjdufer466 3 роки тому +1

    Nice!

  • @kahnbiraj
    @kahnbiraj 2 роки тому +2

    When you call the function like assess_worker or compute_salary, it shows the updated result in the command window. But if you look at the workspace , the value of bonus and total_salary are not updated in the object itself but in the answer object. Can someone explain this to me and how we can update the object property instead?

    • @codethemath4759
      @codethemath4759  2 роки тому +1

      Hi. If I correctly what you ask for, that this is the answer: To change the object property you can define class method for it and then call it in your program, like shown below.
      classdef testClass
      properties
      count
      end
      methods
      function obj = testClass
      obj.count = 1;
      end
      function obj = increment(obj)
      obj.count = obj.count + 1;
      end
      end
      end
      In the exemplary code I presented in this video it was intentional to modify a property value in a particular worker object and not in a class itself.
      I hope it was helpful :-) if so please share the video and live the thumbs up to support my chanel.

    • @kahnbiraj
      @kahnbiraj 2 роки тому

      Thanks for the answer.
      I thought the following function did a similar thing:
      function [theworker] = assess_worker(theworker)

      new_bonus=0.1*mean(theworker.last_scores);
      theworker.bonus=new_bonus;

      end
      Shouldn't this change teh property 'bonus' of the object passed ( in this case W1 or W2 )?
      Did i miss something?

    • @codethemath4759
      @codethemath4759  2 роки тому

      @@kahnbiraj Hi, I have checked this in my old code, the 'bonus' is a public property so you can change a it's value without any function. Just call the object which property you want to edit (in our case let sey W1 as it was called in this video) type jus W1.bonus = new_value. The efect of this statement will be that 'new_value' will be asigned to bonus property of W1 (W1 is the particular instance of class Worker)
      If you need to edit a property of non-public access than this is the case when you need a class method to do it (this kind of method is sometimes called 'seter')
      I hope it will be helpful for you. Have a nice day.

  • @ahmedamr5265
    @ahmedamr5265 3 роки тому

    Great tutorial! Thanks a lot man! :)

  • @mohamadelkhatib34
    @mohamadelkhatib34 3 роки тому

    thanks for the Tutorial. Can you please make an example about calling functions inside the function by using the same method thanks in advance

    • @codethemath4759
      @codethemath4759  3 роки тому

      Hi. I' not exactly sure what you men? Are youinterest in a nested functions? These are particularly usefull when work with callbacks events and GUI's. I planed to make a tutorial about it as well, but if you mean something else please precise your request. Have a nice day :-)

  • @fyang5056
    @fyang5056 3 роки тому

    Thank you !

    • @rhysemerson742
      @rhysemerson742 3 роки тому

      Pro trick : watch series on Flixzone. Been using it for watching a lot of movies recently.

    • @nasirsalvatore2184
      @nasirsalvatore2184 3 роки тому

      @Rhys Emerson yup, I've been using Flixzone} for years myself :)

  • @mberoakoko24
    @mberoakoko24 9 місяців тому

    Just use a real language.

    • @codethemath4759
      @codethemath4759  9 місяців тому

      You mean to do not use Matlab and go with Python instead?

    • @mberoakoko24
      @mberoakoko24 9 місяців тому

      @@codethemath4759 Nope anything other than matlab is prefarable , even Julia is better at representing and handling abstraction compared to matlab.