필터 지우기
필터 지우기

how can I remove duplicate objects (not integers) from an array?

조회 수: 1 (최근 30일)
tombola
tombola 2012년 2월 2일
편집: Adrian 2013년 9월 26일
If I have an array of objects like those below, is there an easy way to remove duplicates please?
So, if two objects in the array have the ShareName of say "Oracle", one of them is removed?
MATLAB code
classdef Quote < handle
properties
ShareName='';
SharePrice=0;
end
Thanks a for any help,
Tom.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2012년 2월 2일
Hi,
something like this?
x = [Quote Quote Quote];
x(1).ShareName = 'foo';
x(2).ShareName = 'bar';
x(3).ShareName = 'foo';
[~,u]=unique({x.ShareName});
% get one of each ShareName:
x = x(u);
Titus

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by