
From:  Nicholas Jankowski 
Subject:  Re: vector function within vector function 
Date:  Tue, 29 Dec 2015 17:45:02 0500 
On Dec 29, 2015 4:57 PM, "ken1866" <address@hidden> wrote:
>
> Hi, I'm brand new to Octave and am trying to understand the concept of vector
> processing. I created the following function that works fine with scalar
> input but when I try vector input I get an error message about nonconformant
> arguments.
>
>
>
> I get that xx and yy are 100x100 and x and y are 1x6 but I don't see why
> that matters. What am I doing wrong and how can I modify to make it work?
> P.S. It works fine if I convert the last statement to a double for loop, but
> that seems like not using Octave as intended. Appreciate any
> comments/suggestions.
>
>
Octave assumes all basic variables are matrices. As such, matrix multiplication rules apply any time you use the * operator for a greater than 1×1 array. The general conformance rule for matrix multiplication is: [m×n] *[n×p] = [m×p]
If you want it to just do vectorised, or element by element, math you want to use .* , .^ and ./ . Also in octave (but not in matlab) if the . operators see something with unequal dimensions it will try to project or broadcast along those other dimensions.
Create a few vectors and arrays and test out different operations from the command line. See what inputs and outputs you get and which give errors. Always a good idea to pull out pieces of failing code to see where results stop doing what you expect
Nick j.
[Prev in Thread]  Current Thread  [Next in Thread] 