Defining structure as a property of a class
Afficher commentaires plus anciens
I defined a class having params property like this. (I removed method part)
It works well but then I notice one-line params definition is hard to follow and for description. I tried the commented codes but it did not work. What would you recommend me to do? Thank you in advance.
classdef CartPole
%CARTPOLE Summary of this class goes here
% Detailed explanation goes here
properties
% field1 = 'length'; value1 = 0.6; % [m]
% field2 = 'mCart'; value2 = 0.5; % [kg]
% field3 = 'mPole'; value3 = 0.5; % [kg]
% field4 = 'fric'; value4 = 0.1; % [N/m/s]
% field5 = 'g'; value5 = 9.82; % [m/s2]
% params = struct(field1,value1,field2,value2,field3,value3,field4,value4,field5,value5)
params = struct('length',0.6,'mCart',0.5,'mPole',0.5,'fric',0.1,'g',9.82)
states = [0;0;0;0] % [x (m); dx (m/s); dtheta (rad/s); theta (rad)]
dstates = [0;0;0;0]
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Enterprise Deployment with MATLAB Production Server dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!