help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Evaluating quadratic functions


From: hanrahat
Subject: Re: Evaluating quadratic functions
Date: Mon, 24 Jan 2005 03:35:31 +0000

A follow up question: why are octave operators targeted to matrices with 
special operators for elements.  Is its basic design centered around matrices?

Thanks,

-- Tom


> Tom,
> 
> Try replacing the exponentiation operator  ^  with the element by
> element exponentiation operator  .^  (dot caret).  Using ^ alone
> computes a matrix power. For that a square matrix is needed. Note that
> for a = [1 2; 3 4] ,  a ^ 2  and a * a give one and the same answer,
> while a .^ 2 and a .* a give one and the same different answer. a must
> be square for the former but not necessarily for the later.  All are
> correct. Which is appropriate, though, depends on your purpose.
> 
> Paul Laub 
> 
> 
> On Mon, 24 Jan 2005 01:50:38 +0000, address@hidden
> <address@hidden> wrote:
> > I'm having trouble understanding how to evaluate and plot quadratic 
> > functions.
> > Here's a sequence that explains what I'm trying to accomplish.  In 
> > particular,
> > I don't understand the error message "error: for A^b, A must be square" It 
> doesn't
> > seem that A being square has anything to do with the function.
> > 
> > Can anyone help me understand how to do this?
> > 
> > Thanks,
> > 
> > -- Tom
> > 
> > GNU Octave, version 2.1.50 (i686-pc-linux-gnu).
> > Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 John W. Eaton.
> > This is free software; see the source code for copying conditions.
> > There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
> > FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.
> > 
> > Please contribute if you find this software useful.
> > For more information, visit http://www.octave.org/help-wanted.html
> > 
> > Report bugs to <address@hidden>.
> > 
> > octave:1> x = 1:1:2;
> > octave:2> sqrt(x)
> > ans =
> > 
> >   1.0000  1.4142
> > 
> > octave:3> exp(x)
> > ans =
> > 
> >   2.7183  7.3891
> > 
> > octave:4> function retval = linear(x)
> > > retval = x + 1;
> > > endfunction
> > octave:5> linear(x)
> > ans =
> > 
> >   2  3
> > 
> > octave:6> function retval = quad(x)
> > > retval = x^2;
> > > endfunction
> > octave:7> quad(x)
> > error: for A^b, A must be square
> > error: evaluating binary operator `^' near line 2, column 11
> > error: evaluating assignment expression near line 2, column 8
> > error: called from `quad'
> > octave:7>
> > 
> > -------------------------------------------------------------
> > Octave is freely available under the terms of the GNU GPL.
> > 
> > Octave's home on the web:  http://www.octave.org
> > How to fund new projects:  http://www.octave.org/funding.html
> > Subscription information:  http://www.octave.org/archive.html
> > -------------------------------------------------------------
> > 
> >



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]