access elements of a vector output in one line

say I have some function output = f(vars), and output is a vector. how can I, in one line, access elements of this vector?
example:
What I want is M and then to plug it into sin(x), the traditional way:
A = ones(2,3);
[M,~] = size(A);
s = sin(M);
An Idea of what I want:
s = sin(size(A){1})
parenthesis gives the result of the function, and the hypothetical curly brackets would return the first element of the result of the function.

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 19 Jun. 2015
Bearbeitet: Azzi Abdelmalek am 19 Jun. 2015

0 Stimmen

s = sin(size(A,1))
Or you can do it this way
s=sin(size(A))*[1;0]
Walter Roberson
Walter Roberson am 19 Jun. 2015

0 Stimmen

IndexAt := @(V, varargin) V(idx, varargin{:});
Then
IndexAt(size(A), 1)

Gefragt:

am 19 Jun. 2015

Beantwortet:

am 19 Jun. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by