matlab - How to loop through a cell array of functions, plotting each one on a different graph -
this attempt 2 functions i'd plot side side:
numgraphs = 2; x = 1:5; y1 = x.^2; y2 = x.^3; funcs = cell(y1, y2); i=1:numgraphs subplot(1,2,i); plot(x,funcs(i)); end
but got error:
error using plot conversion double cell not possible.
is i'm trying possible?
there 2 problems in code:
- creation of cell: should use
funcs = {y1, y2};
, notfuncs = cell(y1, y2);
- plotting: should use
plot(x,funcs{i});
, notplot(x,funcs(i));
. curly braces used access content of cell.
Comments
Post a Comment