Set some values to zero regarding to anothers
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
sbei arafet
il 9 Lug 2016
Risposto: Image Analyst
il 9 Lug 2016
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
0 Commenti
Risposta accettata
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.
0 Commenti
Più risposte (0)
Vedere anche
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!