您的位置:首页 > 其它

Conversion to double from cell is not possible.

2016-05-18 10:21 330 查看
出处:http://cn.mathworks.com/matlabcentral/answers/25332-conversion-to-double-from-cell-is-not-possible

以下代码:

ne_style = { '-r', '-g', '-c', '-xk', '-hm', '-b' };

for i= 1: length(line_style)
plot (A,B,line_style(i),'linewidth',2)


end

%说明:每一次使用plot都使用新的线型。

出现错误: Error using ==> plot Conversion to double from cell is not possible.

解决方案:

plot(A,B,line_style{i},'linewidth',2)

分析:用花括号直接使用line_style本身。使用cell数组里的元素,而不是cell自身

Notice the use of curly brackets to access line_style; that accesses the contents of
that element of the cell array, rather than the cell itself.

举例:

>> filenames{i}

ans =

Firefox 3.0.xlsx

>> filenames(i)

ans =

'Firefox 3.0.xlsx'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: