From: Komson on
Are there any ways to access element in a matrix that returned from a function in a single statement ?

>> magic(3)
ans =
8 1 6
3 5 7
4 9 2

>> ans(1,1)
ans =
8

How can I access element 1,1 of magic(3) without store the result of magic(3) into a variable ?

I have tried "magic(3)(1,1)" and "(magic(3))(1,1)" but it does not work.

Thanks in advance.
From: Matt Fig on
Do a search of this NG, this question seems to be asked about once a month. Short answer is no, this cannot be done. Long answer is yes, it can be done with some kludge.
From: Komson on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hpm9mj$aa4$1(a)fred.mathworks.com>...
> Do a search of this NG, this question seems to be asked about once a month. Short answer is no, this cannot be done. Long answer is yes, it can be done with some kludge.

Thanks for your answer and sorry I did not search before asking the question.

Here is the search result
http://www.mathworks.com/matlabcentral/fileexchange/26570-direct-indexing-of-function-calls-oop-exercise
http://www.mathworks.com/matlabcentral/newsreader/view_thread/275360
http://www.mathworks.com/matlabcentral/newsreader/view_thread/275618