get class name and plot it in variables window.

1 visualización (últimos 30 días)
Le Xuan Thang
Le Xuan Thang el 2 de Oct. de 2024
Comentada: Le Xuan Thang el 3 de Oct. de 2024
Hello everyone!
I have a question about create class
I want to have classname like this in variables window:
val = (classname)
nch: 4
N: 8192
F: 100
df: 0.012207
T: 81.92
dt: 0.01
quantity: force,acc
sifactor: 1
labels: 1F,1A
How can I do that? Thank you all.

Respuestas (1)

Yukthi S
Yukthi S el 2 de Oct. de 2024
I got that you want to create a class with the given properties. Below code is a step-by-step guide to define a MATLAB class.
classdef YourClassName
properties
nch
N
F
df
T
dt
quantity
sifactor
labels
end
methods
% Constructor method to initialize the properties
function obj = YourClassName(nch, N, F, df, T, dt, quantity, sifactor, labels)
if nargin > 0
obj.nch = nch;
obj.N = N;
obj.F = F;
obj.df = df;
obj.T = T;
obj.dt = dt;
obj.quantity = quantity;
obj.sifactor = sifactor;
obj.labels = labels;
end
end
end
end
To create an instance of the class defined and view it in the command window, enter the below code:
val = YourClassName(4, 8192, 100, 0.012207, 81.92, 0.01, 'force,acc', 1, '1F,1A')
You can find the information on creating classes in MATLAB in the below MathWorks documentation:https://www.mathworks.com/help/matlab/matlab_oop/create-a-simple-class.html
  1 comentario
Le Xuan Thang
Le Xuan Thang el 3 de Oct. de 2024
Thank you, But I want to create something like the picture on the left hand side, not the right side

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by