how to ceate a cell array and plot it?

hi, I have performed a regression with last squares so I created a function interpolant called deg2 and the function objective called obj. I would like to plot the obj in order to see if there is only a minimum; I wrote the following code but I don't know how to wrote Ca as a cell array with the same size as X and Y (that are cell arrays of input data)
Ca=linspace(1,10,100); % variable that should be a cell array
Y;% input data (cell array)
X; % input data (cell array)
F=cellfun(@(x,y)obj(y,deg2(Ca,x,VN,Cf1,y(1),x(1))),X,Y,'uni',0);
cellfun(@plot,F,Ca);
I think that F should be a cell array that has the same number of cells as X and Y

5 comentarios

Adam Danz
Adam Danz el 10 de En. de 2020
Editada: Adam Danz el 10 de En. de 2020
" I don't know how to write Ca as a cell array "
Are you looking for this?
Ca = num2cell(linspace(1,10,100))
% Or maybe
Ca = num2cell(linspace(1,10,numel(X)))
Perhaps Ca should be an input to your objective function, too. I'm having trouble imagining what's going on without seeing samples of your variables.
For example, all of these fit your description of X
  • X = {[1 2 3 4]};
  • X = {1 2 3 4};
  • X = {[1 2], [3 4]};
Srivardhan Gadila
Srivardhan Gadila el 14 de En. de 2020
Can you please provide more information on X & Y cell arrays?
Walter Roberson
Walter Roberson el 14 de En. de 2020
I speculate that for each X Y cell array corresponding entries, you expect obj to return with the same length as Ca. I further speculate that you want to plot those results with Ca appearing along an axes.
However I suspect Ca should be along the first dimension, not the second.
Either way, first or second dimension, you have the issue that there is one F entry for each X/Y entry, and it is not clear how you want to plot all of those results in relationship to each other.
Paolo Ottonelli
Paolo Ottonelli el 14 de En. de 2020
thanks to everybody
X and Y are nx1 cell arrays that are real values of an interpolant function, called deg2 . I need to find c, that is parameter of the function above in order to perform a regression. I would like to know the graph of the objective function that depend from c.
Walter Roberson
Walter Roberson el 15 de En. de 2020
You have the issue that there is one F entry for each X/Y entry, and it is not clear how you want to plot all of those results in relationship to each other.
The code you showed us does not have any c, only Ca.
X and Y are nx1 cell arrays that are real values of an interpolant function, called deg2 .
Are X{K} and Y{K} each scalars? Or are they each vectors?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 10 de En. de 2020

Comentada:

el 15 de En. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by