Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
error using plot Conversion to double from cell is not possible.
Replies:
1
Last Post:
Feb 19, 2013 9:10 AM




Re: error using plot Conversion to double from cell is not possible.
Posted:
Feb 19, 2013 9:10 AM


"Caleb Yon" <cy9160@gmail.com> wrote in message <kfujhe$lr9$1@newscl01ah.mathworks.com>... > I do not know why my plot function does not like to plot more than one graph at once. I have tried using the template given in 'help plot' which is: > plot(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) > but it always comes back with: > > Error using plot > Conversion to double from cell is not possible. > > Error in Part_1 (line 18) > plot(THETA, g_THETA, 'b', root1, inter, 'ro',root2, > inter, 'ro',hori, flat, 'm:') > > my code is as follows: > > THETA = linspace(pi, pi, 500); > g_THETA = 3*cos(THETA); > hori = {4, 4}; > flat = {0, 0.000001}; > root1 = {pi/2, pi/2+.00001}; > root2 = {pi/2, pi/2+.000001}; > inter = {0, 3}; > > plot(THETA, g_THETA, 'b', root1, inter, 'ro',root2, inter, 'ro',hori, flat, 'm:') > > does anyone know what I am doing wrong. I have tried a few other things such as putting those strings into a different array and then calling it differently or completely removing it. I want to plot a sin wave from pi to pi with an amplitude of 3 and then show its intersection points on the xaxis with a line going down from there to the bottom of the graph. > > Thank you very much, > Caleb
As the error message indicates, it's not possible to plot a cell array. You have defined several of your plotted variables in that class: hori, flat, root1, root2, inter. It's not clear to me why you have set them as cell arrays rather than just as double or single precision variables, but if you need cell arrays, they in order to plot them, you will need to convert them. See doc cell2mat. You can use it in the same command line with the plot. For example: plot(cell2mat(hori), cell2mat(flat), 'm')



