How to use cellfun?
7 次查看(过去 30 天)
显示 更早的评论
Hello, I have 2 cell arrays (XM and YM), both of them have 3 separated cells. The first array has x values of a certain function while the second has the respective y. I have to perform a non linear regression using the last squares so I created the interpolant function and a objective function to be minimized. Is possible obtain a 3x1 cell where i can find the output patameters without divide the initial arrays using A = cellfun(func,C)?
The following code shows how i have done; it works but I wouldn't like to separate the original arrays'cells
YM=3x1cell
XM=3x1cell
[c1,val1] = fminbnd(@(c0)objfunc(YM1{1},deg(c0,XM{1},'other input parameters')),cm,cM); %deg is my interpolant function, objfunc is my objective function
[c2,val2] = fminbnd(@(c0)objfunc(YM1{2},deg(c0,XM{2},'other input parameters')),cm,cM);
[c3,val3] = fminbnd(@(c0)objfunc(YM1{3},deg(c0,XM{3},'other input parameters')),cm,cM);
0 个评论
采纳的回答
Stephen23
2020-1-9
fun = @(x,y) fminbnd(@(c0)objfunc(y,deg(c0,x,'other input parameters')),cm,cM);
[C,V] = cellfun(fun,XM,YM,'Uni',0)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!