MATLAB: Is there any possible way of writing the following two-line code in one single line

indexing function vectorone line code

Hello all,
I was wondering if it possible to index the solution of a function once you are calling it. The output of the function is a vector and I want to obtain only the n-value of this output.
Example:
S = size(image) % eg. S, the size of the image could be [2046 1807 5]
S3 = S(3) % S3 = 5
What I was trying to do in one single line:
S3 = size(image)(3)
I have been running lately with the need of writing two lines of code instead of one in cases similar to this one. I am not aware of any way of writing this in one single line, but I hope that there is one, otherwise it would be practical to have it implemented.
PS: Suggestion for a better question title are welcome.
Daniel

Best Answer

In a general case, no, you cannot index the result of a function call on a single line. This particular function just happens to have an overload that gives what you want directly.
S = size( image, 3 )
as is shown in
doc size