Automation of the finding size and the number of variables which depends on that size
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Zeynep Naz Kocabas
el 4 de En. de 2020
Comentada: Zeynep Naz Kocabas
el 21 de En. de 2020
for i=1:numDP
data.T{i}=eye(DIM);
nearest=knnsearch(data.DataTree,P(i,:),'K',K+1);
R{i}=zeros(DIM);
for j=1:K
v=P(i,:)-P(nearest(j+1),:);
V11{i}=P(i,:);
V22{i}=P(nearest(j+1),:);
v=v';
s=norm(v);
B=exp(-s^2/sigma^2)*(eye(DIM)-v*v'/norm(v'*v));
R{i}=R{i}+B;
[data.T{i},data.D{i}]=eig(R{i});
n1{i}=data.T{i}(:,1);
N2{i}=data.T{i}(:,2);
n3{i}=data.T{i}(:,3);
lambda1=max(diag(data.D{i}));
lambda3=min(diag(data.D{i}));
lambda2=data.D{i}(2,2);
'My question is for example the number of 'lambda' and 'n' depends on 'DIM'. But as you can see this code works just for DIM=3; I need to generalize that code for every dimensions and my Matlab knowledge is not enough to do as a beginner. I put example to make it clear
2 comentarios
Walter Roberson
el 14 de En. de 2020
Replace
n1{i}=data.T{i}(:,1);
N2{i}=data.T{i}(:,2);
n3{i}=data.T{i}(:,3);
with
c = size(data.T{i},2);
for K = 1 : c
N{c}{i} = data.T{i}(:,K);
end
... But it doesn't look like a useful memory organization to me. Why not just store all of data.T{i} ?
Respuesta aceptada
Mahesh Taparia
el 8 de En. de 2020
Hi
The function ‘knnsearch’ can work for N dimensional data. By looking at your code, it seems the value of DIM will be the number of elements in P(i,:), if you want to increase the DIM, change the data accordingly.
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays 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!