The role of singleton elements in calls to the zeros function.
이전 댓글 표시
Hello MatLab'rs,
I'm confused by the return of zeros under certain circumstances.
For some vector V, calling zeros will create a length(V) dimensional matrix:
>> V = [ 1:10 ]
V =
1 2 3 4 5 6 7 8 9 10
>> Z = zeros(V); % Z = <10-D double>
In my code I have a selectedDimLengths vector, each element of which can change from a singleton up to about 6 or 7, but often looks something like:
selectedDimLengths =
1 1 1 5 5 1 1 1 3 1 1 1 1
>> Z = zeros(selectedDimLengths); % Z = <9-D double>
when I pass this to zeros I lose a couple of dimensions, down to 9 when I expect 13. What role do the singleton elements play here? Why?
Are the trailing singleton elements cropped somehow?
채택된 답변
추가 답변 (1개)
Iain
2014년 10월 2일
0 개 추천
Matlab only really needs to know which dimensions are "nonsingular". - A scalar has infinite dimensions, all with a size of 1. - A vector has infinite dimensions, only one of which has a size other than 1.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!