How to use cellfun?

5 vues (au cours des 30 derniers jours)
Paolo Ottonelli
Paolo Ottonelli le 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);

Réponse acceptée

Stephen23
Stephen23 le 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)
  1 commentaire
Paolo Ottonelli
Paolo Ottonelli le 9 Jan 2020
Thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by