Hi all!
Firstly, I am not exactly sure this is possible, so forgive me if I am asking a redundant question.
I have a series of objects that are same in structure, and I want to group them into an array to keep them together. However, upon initializing such an object with a function, it returns a 2-D matrix, and the program gives me an error: "Subscripted assignment dimension mismatch.". This is the code:
T(1) = makehgtform('translate', [1 1 0]);
T(2) = makehgtform('translate', [1 -1 0]);
T(3) = makehgtform('translate', [-1 1 0]);
T(4) = makehgtform('translate', [-1 -1 0]);
I hope you understand what I'm trying to do, and what the problem is.
Thanks in advance! :)

 채택된 답변

Stephen23
Stephen23 2017년 10월 1일
편집: Stephen23 2017년 10월 1일

0 개 추천

Into a 3D array:
T = nan(4,4,N);
T(:,:,1) = makehgtform('translate', [1,1,0]);
T(:,:,2) = makehgtform('translate', [1,-1,0]);
etc
Or a cell array:
T = cell(1,N);
T{1} = makehgtform('translate', [1,1,0]);
T{2} = makehgtform('translate', [1,-1,0]);
etc
Where N is the number of matrices you will have.

댓글 수: 3

Filip Davidovic
Filip Davidovic 2017년 10월 1일
I get the exact same error.
Filip Davidovic
Filip Davidovic 2017년 10월 1일
I get the error: "Cell contents assignment to a non-cell array object.".
Stephen23
Stephen23 2017년 10월 1일
@Filip Davidovic: you need to preallocate the matrix or cell array, as shown in my answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2017년 10월 1일

댓글:

2017년 10월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by