1

Possible Duplicate:
matlab array index without assigning to a local variable

Hi All,

I am having a very basic question in using matlab. I want to save the use of a in the following code when using matlab:

a=[1,2,3]
a(2:3)

[1,2,3](2:3) is now allowed.

??? [1 2 3](2:3)

|

Error: Unbalanced or misused parentheses or brackets.

Is there any function to get the element of a vector besides the [] operator? The reason I ask this is that: sometimes when a function returns a vector and I want to get only the second element in the vector, I do not want to save the function return to a temporary variable before I get its second element. Is there any way?

Many thanks!

Failed Scientist
  • 1,977
  • 3
  • 29
  • 48
Qiang Li
  • 10,593
  • 21
  • 77
  • 148
  • 4
    Questions along this same line have been asked before: [matlab array index without assigning to a local variable](http://stackoverflow.com/questions/3627107), [How to elegantly ignore some return values of a MATLAB function?](http://stackoverflow.com/questions/747296), [How do I get the second return value from a function without using temporary variables?](http://stackoverflow.com/questions/3710466) – gnovice Dec 07 '10 at 01:06
  • @gnovice: And here I was about to say it wasn't possible :) – Jonas Dec 07 '10 at 01:18
  • by "now allowed" do you mean "not allowed"? – btown Dec 07 '10 at 18:38

1 Answers1

1

This might be of interest:

File Central - Direct Indexing of Function Calls

Chris
  • 1,532
  • 10
  • 19