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
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
add a comment |
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
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
add a comment |
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
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
arrays matlab multidimensional-array
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
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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