[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: x^y question
From: |
LUK ShunTim |
Subject: |
Re: x^y question |
Date: |
Wed, 06 Dec 2006 20:02:33 +0800 |
User-agent: |
Icedove 1.5.0.8 (X11/20061128) |
huub wrote:
> Hi,
>
> I'm trying to plot a couple of simple functions like y = x^2 + 2*x + 10,
> but I got these errors:
>
> error: for A^b, A must be square
> error: evaluating binary operator `^' near line 4, column 7
> error: evaluating binary operator `+' near line 4, column 10
> error: evaluating binary operator `+' near line 4, column 14
> error: evaluating assignment expression near line 4, column 4
> error: called from `test' in file `/home/huub/test.m'
>
> When reading the online manual, I notice 2 things:
> - the main topic is matrices
> - the power-operator (^ and **) implementation needs improvement
>
> Can I plot simple functions like this using Octave? I tried in Scilab,
> and have no problems at all.
>
> Thank you
>
> Huub
Try this:
x=0:0.1:3;
y = x .^2 + 2*x + 10;
plot(x,y);
Note the .^ which is an element-by-element operation. So is .* and ./
The most updated documentation is at
http://octave.sourceforge.net/index/index.html
Regards,
ST
--