calling seperate members of a vector function

3 次查看(过去 30 天)
I want to call seperate members of my defined vector function and I don't know how to do it.
For example I defined the vector function as shown:
F=@(x,y,z) [x- y, y^2 , z+2] which shows:
@(x, y, z) [x - y, y ^ 2, z + 2]
how do i call only one member, like the first one "x-y"? Because if I do F(1) I'm defining x as equal to 1.

采纳的回答

Matt J
Matt J 2021-10-26
编辑:Matt J 2021-10-26
There's no way to do that. You could do it if the components are held in struct form, e .g.,
F=@(x,y) struct('a',x-y,'b', y^2);
F(5,3).a
ans = 2
  2 个评论
Matt J
Matt J 2021-10-28
You're welcome, but if you consider your question answered, please Accept-click the answer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by