Borrar filtros
Borrar filtros

How to find the distance between vectors whose coordinates are stored in different arrays.

1 visualización (últimos 30 días)
Hi,
I get the error:??? Cell contents assignment to a non-cell array object. at this line in my code:
for k=1:N
A{k}=zeros(length(m),2);
end
That's my first problem. Assuming that I figure out how to solve my first problem, I have another problem: once I have stored values in A{N}, I would like to compute
A{1}(1,:)-A{2}(1,:), A{1}(2,:)-A{2}(2,:), A{1}(3,:)-A{2}(3,:), ..., A{1}(n,:)-A{2}(n,:)
A{2}(1,:)-A{3}(1,:), A{2}(2,:)-A{3}(2,:), A{2}(3,:)-A{3}(3,:), ... , A{2}(n,:)-A{3}(n,:)
A{3}(1,:)-A{4}(1,:), A{3}(2,:)-A{4}(2,:), A{3}(3,:)-A{4}(3,:), ... , A{3}(n,:)-A{4}(n,:)
.
.
.
A{N-1}(1,:)-A{N}(1,:), A{N-1}(2,:)-A{N}(2,:), A{N-1}(3,:)-A{N}(3,:),..., A{N-1}(n,:)-A{N}(n,:)
and store these values into an n X N matrix.
I know I'm gonna find some help here, I always do.
Please help me solve my two problems.
Thanks.
  1 comentario
Matt J
Matt J el 11 de Mzo. de 2013
Your example doesn't lead to an n X N matrix. Each A{i}(j,:) is a 1x2 vector, so this leads to a N-1 x 2*n matrix.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 11 de Mzo. de 2013
Editada: Matt J el 11 de Mzo. de 2013
Your first problem.
A=cell(N,1);
for k=1:N
A{k}=zeros(length(m),2);
end
  5 comentarios
Matt J
Matt J el 11 de Mzo. de 2013
Errors like these are a job for the debugger. Set a breakpoint at line 55 in ImagExperiment and rerun your code. When the code halts at line 55, run
z=cellfun(@(c) size(c), A,'uni',0); z{:}
at the K>> prompt and show us the output.
MatlabFan
MatlabFan el 11 de Mzo. de 2013
Hi Matt, I found a way around this. And yes, I thank you for your great help. Now, I am experiencing other issues with my code.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by