Azzera filtri
Azzera filtri

Set some values to zero regarding to anothers

2 visualizzazioni (ultimi 30 giorni)
Hi, i want to set all values different from wx vector to zero
index=find(labels==0);
wx=full(T(index,1));% vector containing values to not be setted to zero
elements=full(T(:,1));
indexmr=find(~ismember(elements,wx));% find index of elements in elements not equal to wx
elements(indexmr)=0;% set values to zero
the problem that there exists values that are not setted to zero and does'nt exist in wx
size(wx)
155 1
size(find(elements))
176 1
i have tried also
elements=zeros(size(T(:,1)));
for j=1: size(elements,1)
for i=1: size(index,1)
if (index(i)==j)
elements(j)=T(index(i),1);
end
end
end
size(find(elements))
115 1
Thnaks in advance

Risposta accettata

Image Analyst
Image Analyst il 9 Lug 2016
Please give some data with desired output. It's not clear what you want.
For example to "set all values different from wx vector to zero" you could do
% Find indexes where labels is different from wx.
indexesThatDontMatch = labels ~= wx;
% Now set to zero.
labels(indexesThatDontMatch) = 0;
Or maybe it's possible you want the setdiff(): "C = setdiff(A,B) returns the data in A that is not in B." I'm not sure until you clarify some more by showing input and output data.

Più risposte (0)

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by