How to find the distance between vectors whose coordinates are stored in different arrays.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Matt J
2013년 3월 11일
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.
답변 (1개)
Matt J
2013년 3월 11일
편집: Matt J
2013년 3월 11일
Your first problem.
A=cell(N,1);
for k=1:N
A{k}=zeros(length(m),2);
end
댓글 수: 5
Matt J
2013년 3월 11일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!