How to extract property values from an object array and put it into a new array?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nirmal Hirani
el 13 de Oct. de 2022
classdef Datatest
properties (SetAccess = 'public' ,GetAccess = 'public')
Name
end
end
% creating 4 objects of the class 'Datatest'
x1 = Datatest();
x2 = Datatest();
x3 = Datatest();
x4 = Datatest();
% Changing the name of each objects property
x1.Name = 'test1';
x2.Name = 'test2';
x3.Name = 'test3';
x4.Name = 'test4';
% array of objects
list = [x1 x2 x3 x4]
dropDown = zeros(1,4)
for i=1:4
dropDown(i) = list(i).Name
end
i would like to create an array called 'dropDown' and extract all the names of objects from the object list. I tried this code which is giving me an arror "Unable to perform assignment because the left and right sides have a different number of elements."
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!