How to use cellfun?

4 views (last 30 days)
Paolo Ottonelli
Paolo Ottonelli on 9 Jan 2020
Commented: Paolo Ottonelli on 9 Jan 2020
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);

Accepted Answer

Stephen23
Stephen23 on 9 Jan 2020
fun = @(x,y) fminbnd(@(c0)objfunc(y,deg(c0,x,'other input parameters')),cm,cM);
[C,V] = cellfun(fun,XM,YM,'Uni',0)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!