Return first unique index of values

7 Ansichten (letzte 30 Tage)
Kalai Arasi Mehavarnam
Kalai Arasi Mehavarnam am 18 Okt. 2018
Kommentiert: Guillaume am 18 Okt. 2018
%function [mu,sig,p] = cifar_10_bayes_learn1(f, trlabel,N)
%trlabel=tr_labels(1:100)';
label=[1:10,2:11,3:12];
%N=16;
mu = zeros(10,(N*3));
%sig = zeros(10,3) %task1
sig = zeros((N*3),(N*3),10); %task2
p = zeros(10,1);
for i = 1:10
[row] = (find(label==i));
%[row] = find(trlabel==i-1)
for j=1:N
mu(i,j) = mean(f((row(i,j))));
mu(i,j+N) = mean(f((row(i,j+N))));
mu(i,(j+(2*N))) = mean(f((row(i,(j+(2*N))))));
end
mu(i,:)=[mu(i,j),mu(i,j+N),mu(i,(j+(2*N)))] %error in this, suscripted assignment dimension mismatch
% sig(:,:,i) = cov(f((row),:))
% %Sig(:,:,i)=(cov(f(row))+cov(f(row),:).')/2;
% p(i) = (length(row) / length(f))
end
end
The above code has to return 10 values in row vector,ie, the first index of unique values.The row values should be displayed as 1,2,3,...,10. I wanted to calculate mean,sigma for that particular indexed rows in training data.
  2 Kommentare
madhan ravi
madhan ravi am 18 Okt. 2018
Bearbeitet: madhan ravi am 18 Okt. 2018
Provide the input datas to test
Guillaume
Guillaume am 18 Okt. 2018
We have no idea what the above code is supposed to do since it's not commented. In addition, it's littered with unnecessary brackets making it harder to read (in my opinion), e.g. the line
mu(i,(j+(2*N))) = mean(f((row(i,(j+(2*N))))));
is simply
mu(i, j+2*N) = mean(f(row(i, j+2*N)));
You should explain the problem you're trying to solve in details, rather than giving us uncommented code that may or may not work.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by