Storing the inputs of a function on a structure (or cell or array)
1 次查看(过去 30 天)
显示 更早的评论
given a function such as:
function [z,w] = tempFun(x,y)
z = x+1;
w = y+1;
end
is it possible to store a given pair x,y as a structure (struct('x',1,'y',2), say, or as a cell or anything else...) and then unpack it and apply the function to the output?
(In python this could be done as: temFun( **{'x':1, 'y':2})
0 个评论
采纳的回答
madhan ravi
2019-8-15
d=struct('x',1,'y',2);
[z,w] = tempFun(d)
function [z,w] = tempFun(s)
z = s.x+1;
w = s.y+1;
end
6 个评论
madhan ravi
2019-8-15
编辑:madhan ravi
2019-8-15
Well, I'm a beginner in python (didn't get to this point still) , but this topic would be interesting to be debate about. But then do not underestimate the power of MATLAB ;-)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!