1

I am developmenting a software using App Designer in Matlab. First, the user input some values in Edit Texts, in App Designer. After this, I send this values to a constructor class called Class_TNT. So, I am trying conect this constructor with another class that I created, called Class_Load (that class have some functions to calculate some parameters). But the Class_Load get the default values of constructor class. It's crazy because when I use the breakpoint in constructor class, all parameters has the values that user input in App Designer. Can you help me? Kind regards, Ana Reis

Here, the public properties in App Designer

    properties (Access = public)
        plate = [];
        tnt = [];
    end

Here, the code in Run Button, in App Designer

    function RunButton_GeneralPushed(app, event)
            % Avaliating parameters
            [sup, type_sup, type, nonlinear, negative] = app.Avaliating...
                (app.SupportPlate.Value, app.SupportMembrane.Value, ...
                app.TypeExplosion.SelectedObject.Text,...
                app.NonlinearAnalisys.SelectedObject.Text, ...
                app.NegativePhase.SelectedObject.Text);
            
            % Sending values to constructor method
            app.plate = Class_Plate...
                (sup, type_sup, app.app_a.Value, app.app_beta.Value, ...
                app.app_h.Value, app.app_nu.Value, app.app_E.Value, ...
                app.app_rho.Value, nonlinear, app.TimeAnalysis.Value);
            
            app.tnt = Class_TNT...
                (app.app_W.Value, app.app_Z.Value, type, negative);

Here, the constructor Class_TNT

classdef Class_TNT
    properties (SetAccess = public, GetAccess = public)
        Z = 0;
        W = 0;
        type = 0;
        negative = 0;
    end
    
    methods
        function tnt = Class_TNT(W, Z, type, negative, varargin)
            if (nargin > 0)
                tnt.W            = W;
                tnt.Z            = Z;
                tnt.type         = type;
                tnt.negative     = negative;
            else
                tnt.W            = 129.45;
                tnt.Z            = 27.7;
                tnt.type         = 1;
                tnt.negative     = 1;                
            end
        end
    end
end

And here, the Class_Load (not totally)

classdef Class_Load < Class_TNT
    properties (SetAccess = public, GetAccess = public)
       td              = 0;
    end
    
    methods
        function blast = Class_Load(W, Z, type, negative)
            blast = blast@Class_TNT();
            if (nargin > 0)
                blast.W           = W;
                blast.Z           = Z;
                blast.type        = type;
                blast.negative    = negative;
            end
            blast.td            = blast.Positive_Time();
        end
    end
    
    methods
        function td = Positive_Time(blast)
            Z       = blast.Z;
            W       = blast.W;
            type    = blast.type;
            
            switch type
                case 1
                   td = 0.001 * ( 2.2064 * Z^3 - 0.3363 * Z^2 - ...
                            0.5644 * Z + 0.3756 ) * ( W^(1/3) );
                case 2
                   td = 0.001 * ( 4.2668 * Z^3 - 1.9736 * Z^2 + ...
                            0.132 * Z + 0.2145 ) * ( W^(1/3) );                    
            end
            
        end
    end
end
Andrew Janke
  • 23,508
  • 5
  • 56
  • 85
  • Hi @Ana! Welcome to Stack Overflow. I don't see any actual references to `Class_Load` anywhere in this code? Where is a `Class_Load` object being created? And your code is referencing a `Class_Plate`, but I don't see a definition for that? – Andrew Janke Jun 23 '20 at 01:20
  • Other than that, your class definitions themselves look fine. (Though, style-wise, it's conventional to name the class object argument `this` or `obj` instead of something domain-specific like `blast` or `tnt`.) – Andrew Janke Jun 23 '20 at 01:23
  • Yeah, I didn't put Class_Plate because this class is similar to Class_TNT. So, if I resolve Class_TNT, the same think I can apply in Class_Plate. – Ana Waldila Jun 23 '20 at 02:00
  • About the Class_Load, I use this class in another 4 classes. So, If I put all of them, there won't be looks fine here rsrs. Beside that, my code runs well and an output results in App Designer is presented, but with default value of Class_TNT (and defaulf values of Class_Plate, of course...). – Ana Waldila Jun 23 '20 at 02:05
  • I agree with you. I see in Matlab's documentation the use of 'obj'. But I prefer to use a specific name. – Ana Waldila Jun 23 '20 at 02:08
  • 2
    Please read [mre]. The idea is not to show part of your code, but to create new code that contains the essential parts only, that we can copy and run, and which demonstrates the issue you have. Yes, it can be a lot of work, but it’s the only way we’ll understand what you are doing and where the problem is. The bits you posted seem OK, I think the problem might be elsewhere. – Cris Luengo Jun 23 '20 at 02:11
  • Ok! Thank you soo much! I will try to do this! – Ana Waldila Jun 23 '20 at 02:42

0 Answers0