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};, not funcs = cell(y1, y2);
  • plotting: should use plot(x,funcs{i});, not plot(x,funcs(i));. curly braces used access content of cell.

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -