Why is MATLAB not hiding 2D trailing singleton dimension?With arrays, why is it the case that a[5] == 5[a]?Why is using “for…in” with array iteration a bad idea?Numpy array dimensionsDifferences between Octave and MATLAB?Use a vector to index a matrix without linear indexCheck matrix size with potential trailing singleton dimension in matlabSqueeze Some of Singleton Dimensions in MatlabMatlab trailing singleton dimensionEfficient Method in MATLAB for Producing a Numerical Solution to an Ordinary Differential EquationAdvanced Matlab: colon indexing of singleton dimension in assignment

Does Dhp 256-257 condone judging others?

How can solar sailed ships be protected from space debris?

Trace in the category of propositional statements

Why are symbols not written in words?

Why would Dementors torture a Death Eater if they are loyal to Voldemort?

I agreed to cancel a long-planned vacation (with travel costs) due to project deadlines, but now the timeline has all changed again

How far can gerrymandering go?

SQL Server Ignoring Instance name when using port number of different instance

How can I change my buffer system for protein purification?

Which are more efficient in putting out wildfires: planes or helicopters?

Robots in a spaceship

Could citing a database like libgen get one into trouble?

2019 2-letters 33-length list

What could a Medieval society do with excess animal blood?

What is this fluorinated organic substance?

Are all notation equal by derivatives?

German idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)

Old story where computer expert digitally animates The Lord of the Rings

Yum in Amazon Linux 2 still asks for GPG key even after "rpm --import" when adding Kubernetes repo

Advantages of using bra-ket notation

Can combing bent evaporator coil fins damage it?

Does friction always oppose motion?

Why was Pan Am Flight 103 flying over Lockerbie?

Is it OK to say "The situation is pregnant with a crisis"?



Why is MATLAB not hiding 2D trailing singleton dimension?


With arrays, why is it the case that a[5] == 5[a]?Why is using “for…in” with array iteration a bad idea?Numpy array dimensionsDifferences between Octave and MATLAB?Use a vector to index a matrix without linear indexCheck matrix size with potential trailing singleton dimension in matlabSqueeze Some of Singleton Dimensions in MatlabMatlab trailing singleton dimensionEfficient Method in MATLAB for Producing a Numerical Solution to an Ordinary Differential EquationAdvanced Matlab: colon indexing of singleton dimension in assignment













3















A MATLAB array has an infinite number of trailing singleton dimension (theoretically).



So a 1x10 array is in fact a 1x10x1x1x1... array. I suppose that MATLAB just hides the trailing singleton dimension.



You can observe this behaviour with this code snippet:



permute([1:10],[2,1,4,3])


MATLAB deals with permuting the 3rd and 4th dimension without any problem even if it's a 1D array.



But why does MATLAB not hide the trailing singleton dimension in the 2nd dimension?




size(rand(10,1))


gives:



ans =

10 1



size(rand(10,1,1))


also gives:



ans =

10 1


Is that because MATLAB is optimized for linear algebra? So, is it simply a convention?










share|improve this question



















  • 2





    By definition, MATLAB arrays always have at least two dimensions. This is by design. Originally, everything was 2D. At some point they introduced higher-dimensional arrays (I think this was MATLAB 5, but am not sure). But I guess they couldn't remove the last singleton dimension to allow 1D arrays because it would break a lot of code.

    – Cris Luengo
    Mar 25 at 17:11











  • Ho you're right, I've just found this explaination: "Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions. Trailing singleton dimensions past the second are not displayed or reported on, e.g., with size. No array has fewer than two dimensions. Empty arrays are the logical extension of general arrays but have at least one size 0 dimension. The syntax [] denotes the empty array of size 0x0 and is treated as an exception occasionally (for backward compatibility)"

    – obchardon
    Mar 25 at 17:19












  • That quote should read "Arrays in MATLAB are N-dimensional, with N ∈ [2,∞)." :)

    – Cris Luengo
    Mar 25 at 17:23
















3















A MATLAB array has an infinite number of trailing singleton dimension (theoretically).



So a 1x10 array is in fact a 1x10x1x1x1... array. I suppose that MATLAB just hides the trailing singleton dimension.



You can observe this behaviour with this code snippet:



permute([1:10],[2,1,4,3])


MATLAB deals with permuting the 3rd and 4th dimension without any problem even if it's a 1D array.



But why does MATLAB not hide the trailing singleton dimension in the 2nd dimension?




size(rand(10,1))


gives:



ans =

10 1



size(rand(10,1,1))


also gives:



ans =

10 1


Is that because MATLAB is optimized for linear algebra? So, is it simply a convention?










share|improve this question



















  • 2





    By definition, MATLAB arrays always have at least two dimensions. This is by design. Originally, everything was 2D. At some point they introduced higher-dimensional arrays (I think this was MATLAB 5, but am not sure). But I guess they couldn't remove the last singleton dimension to allow 1D arrays because it would break a lot of code.

    – Cris Luengo
    Mar 25 at 17:11











  • Ho you're right, I've just found this explaination: "Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions. Trailing singleton dimensions past the second are not displayed or reported on, e.g., with size. No array has fewer than two dimensions. Empty arrays are the logical extension of general arrays but have at least one size 0 dimension. The syntax [] denotes the empty array of size 0x0 and is treated as an exception occasionally (for backward compatibility)"

    – obchardon
    Mar 25 at 17:19












  • That quote should read "Arrays in MATLAB are N-dimensional, with N ∈ [2,∞)." :)

    – Cris Luengo
    Mar 25 at 17:23














3












3








3








A MATLAB array has an infinite number of trailing singleton dimension (theoretically).



So a 1x10 array is in fact a 1x10x1x1x1... array. I suppose that MATLAB just hides the trailing singleton dimension.



You can observe this behaviour with this code snippet:



permute([1:10],[2,1,4,3])


MATLAB deals with permuting the 3rd and 4th dimension without any problem even if it's a 1D array.



But why does MATLAB not hide the trailing singleton dimension in the 2nd dimension?




size(rand(10,1))


gives:



ans =

10 1



size(rand(10,1,1))


also gives:



ans =

10 1


Is that because MATLAB is optimized for linear algebra? So, is it simply a convention?










share|improve this question
















A MATLAB array has an infinite number of trailing singleton dimension (theoretically).



So a 1x10 array is in fact a 1x10x1x1x1... array. I suppose that MATLAB just hides the trailing singleton dimension.



You can observe this behaviour with this code snippet:



permute([1:10],[2,1,4,3])


MATLAB deals with permuting the 3rd and 4th dimension without any problem even if it's a 1D array.



But why does MATLAB not hide the trailing singleton dimension in the 2nd dimension?




size(rand(10,1))


gives:



ans =

10 1



size(rand(10,1,1))


also gives:



ans =

10 1


Is that because MATLAB is optimized for linear algebra? So, is it simply a convention?







arrays matlab multidimensional-array






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 18:58









Sardar Usama

16.3k8 gold badges27 silver badges49 bronze badges




16.3k8 gold badges27 silver badges49 bronze badges










asked Mar 25 at 17:07









obchardonobchardon

4,7261 gold badge8 silver badges22 bronze badges




4,7261 gold badge8 silver badges22 bronze badges







  • 2





    By definition, MATLAB arrays always have at least two dimensions. This is by design. Originally, everything was 2D. At some point they introduced higher-dimensional arrays (I think this was MATLAB 5, but am not sure). But I guess they couldn't remove the last singleton dimension to allow 1D arrays because it would break a lot of code.

    – Cris Luengo
    Mar 25 at 17:11











  • Ho you're right, I've just found this explaination: "Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions. Trailing singleton dimensions past the second are not displayed or reported on, e.g., with size. No array has fewer than two dimensions. Empty arrays are the logical extension of general arrays but have at least one size 0 dimension. The syntax [] denotes the empty array of size 0x0 and is treated as an exception occasionally (for backward compatibility)"

    – obchardon
    Mar 25 at 17:19












  • That quote should read "Arrays in MATLAB are N-dimensional, with N ∈ [2,∞)." :)

    – Cris Luengo
    Mar 25 at 17:23













  • 2





    By definition, MATLAB arrays always have at least two dimensions. This is by design. Originally, everything was 2D. At some point they introduced higher-dimensional arrays (I think this was MATLAB 5, but am not sure). But I guess they couldn't remove the last singleton dimension to allow 1D arrays because it would break a lot of code.

    – Cris Luengo
    Mar 25 at 17:11











  • Ho you're right, I've just found this explaination: "Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions. Trailing singleton dimensions past the second are not displayed or reported on, e.g., with size. No array has fewer than two dimensions. Empty arrays are the logical extension of general arrays but have at least one size 0 dimension. The syntax [] denotes the empty array of size 0x0 and is treated as an exception occasionally (for backward compatibility)"

    – obchardon
    Mar 25 at 17:19












  • That quote should read "Arrays in MATLAB are N-dimensional, with N ∈ [2,∞)." :)

    – Cris Luengo
    Mar 25 at 17:23








2




2





By definition, MATLAB arrays always have at least two dimensions. This is by design. Originally, everything was 2D. At some point they introduced higher-dimensional arrays (I think this was MATLAB 5, but am not sure). But I guess they couldn't remove the last singleton dimension to allow 1D arrays because it would break a lot of code.

– Cris Luengo
Mar 25 at 17:11





By definition, MATLAB arrays always have at least two dimensions. This is by design. Originally, everything was 2D. At some point they introduced higher-dimensional arrays (I think this was MATLAB 5, but am not sure). But I guess they couldn't remove the last singleton dimension to allow 1D arrays because it would break a lot of code.

– Cris Luengo
Mar 25 at 17:11













Ho you're right, I've just found this explaination: "Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions. Trailing singleton dimensions past the second are not displayed or reported on, e.g., with size. No array has fewer than two dimensions. Empty arrays are the logical extension of general arrays but have at least one size 0 dimension. The syntax [] denotes the empty array of size 0x0 and is treated as an exception occasionally (for backward compatibility)"

– obchardon
Mar 25 at 17:19






Ho you're right, I've just found this explaination: "Arrays in MATLAB are N-dimensional, with an infinite number of trailing singleton dimensions. Trailing singleton dimensions past the second are not displayed or reported on, e.g., with size. No array has fewer than two dimensions. Empty arrays are the logical extension of general arrays but have at least one size 0 dimension. The syntax [] denotes the empty array of size 0x0 and is treated as an exception occasionally (for backward compatibility)"

– obchardon
Mar 25 at 17:19














That quote should read "Arrays in MATLAB are N-dimensional, with N ∈ [2,∞)." :)

– Cris Luengo
Mar 25 at 17:23






That quote should read "Arrays in MATLAB are N-dimensional, with N ∈ [2,∞)." :)

– Cris Luengo
Mar 25 at 17:23











0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343061%2fwhy-is-matlab-not-hiding-2d-trailing-singleton-dimension%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343061%2fwhy-is-matlab-not-hiding-2d-trailing-singleton-dimension%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해