fevaln: feval with control of the order of the outputs

版本 1.0.0.0 (1.4 KB) 作者: Sky Sartorius
Return the nth output first. Especially useful for defining anonymous functions for use with search.
140.0 次下载
更新时间 2015/10/16

查看许可证

Syntax: [y1,...,yn] = fevaln(ind,f,x1,...,xn)
ind - Index of output to return or vector of indices to determine the order of outputs.
f - Function handle or function name.
x1,...,xn - Function arguments.
y1,...,yn - Output arguments returned in the desired order.

Examples from help:
Example 1: Find y coordinate of a point at x = pi that is 5 units away from the origin.
f = @(y) fevaln(2,'cart2pol',pi,y) - 5;
y = fzero(f,4)

Example 2: Create an anonymous function mysize that return dimensions of the input as [N,M] instead of [M,N].
mysize = @(x) fevaln([2,1],'size',x)
x = repmat(zeros(5,7),2,3);
[m1,n1] = size(x)
[n2,m2] = mysize(x)
arrayWidth = mysize(x)

Source: http://www.mathworks.com/matlabcentral/cody/problems/266/solutions/30480

引用格式

Sky Sartorius (2024). fevaln: feval with control of the order of the outputs (https://www.mathworks.com/matlabcentral/fileexchange/53552-fevaln-feval-with-control-of-the-order-of-the-outputs), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2015b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Shifting and Sorting Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0