2013-10-07 13 views
0

绘制每个人这是我尝试用2个功能,我想通过边绘制边:如何通过功能的单元阵列循环,在不同的图形

numgraphs = 2; 
x = 1:5; 
y1 = x.^2; 
y2 = x.^3; 

funcs = cell(y1, y2); 

for i=1:numgraphs 
    subplot(1,2,i); 
    plot(x,funcs(i)); 
end 

但我得到这个错误:

Error using plot 
Conversion to double from cell is not possible. 

正是我想要做的可能吗?

回答

4

有在你的代码两个问题:电池的

  • 创作:你应该使用funcs = {y1, y2};,不funcs = cell(y1, y2);
  • 绘图:你应该使用plot(x,funcs{i});,不plot(x,funcs(i));。花括号用于访问单元的内容