Path: news.mathworks.com!not-for-mail From: "Steven Lord" <slord@mathworks.com> Newsgroups: comp.soft-sys.matlab Subject: Re: [how to make] a plot of x to the x Date: Mon, 23 Feb 2009 10:45:22 -0500 Organization: The MathWorks, Inc. Lines: 49 Message-ID: <gnugai$ra8$1@fred.mathworks.com> References: <c13f048a-c8ee-4888-8842-35d351bf44e8@t13g2000yqc.googlegroups.com> Reply-To: "Steven Lord" <slord@mathworks.com> NNTP-Posting-Host: lords.dhcp.mathworks.com X-Trace: fred.mathworks.com 1235403922 27976 144.212.105.187 (23 Feb 2009 15:45:22 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Mon, 23 Feb 2009 15:45:22 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: news.mathworks.com comp.soft-sys.matlab:520210 <congruentialuminaire@yahoo.com> wrote in message news:c13f048a-c8ee-4888-8842-35d351bf44e8@t13g2000yqc.googlegroups.com... > Hello UG: > > I want to make a plot of this function. > > I can differentiate it if I use: > > syms x > y=x^x > diff(y,x) > > but when I try to plot, I get: > > plot(y,x) > ??? Error using ==> plot > Conversion to double from sym is not possible. Yes. PLOT does not support sym objects; you'll need to evaluate the sym object using SUBS and convert it to double precision using DOUBLE before you can PLOT it. Alternately, you could use EZPLOT. > I can also do this: > > w=[0;0.1;5]; > u=w^w > > but Matlab says: > > ??? Error using ==> mpower > At least one operand must be scalar. When you use w^w, you're trying to raise the matrix w to the wth power. That doesn't make sense unless w is a scalar (what does it mean to raise [1 2] to the [1 2] power?) What you want is to raise each element of w to the power of the corresponding element of w. To do that, you need the elementwise POWER operator (.^). w = [0; 0.1; 5]; u = w.^w; -- Steve Lord slord@mathworks.com