The role of singleton elements in calls to the zeros function.
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (1)
Iain
il 2 Ott 2014
0 voti
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.
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!