help-octave
[Top][All Lists]

## Re: printing mesh with unequal ranges

 From: Andy Buckle Subject: Re: printing mesh with unequal ranges Date: Fri, 1 Apr 2011 15:34:36 +0100

```On Fri, Apr 1, 2011 at 3:05 PM, Huub van Niekerk
> On Fri, Apr 1, 2011 at 2:29 PM, Ben Abbott <address@hidden> wrote:
>>
>> On Apr 1, 2011, at 8:20 AM, Huub van Niekerk wrote:
>>
>> > Hi,
>> >
>> > I'm trying to plot a function along a meshgrid using x = 0 : 6 and y = 0
>> > : 10, and e.g. function f = 2 * x * sin(2*pi*y) + 4 * x * cos(2*pi*y)
>> > I'm getting the error that the matrix A^b must be square. I understand
>> > that, but then how can I get what I want? Reading the documentation it only
>> > deals with 1 variable in the function. Can somebody please tell me what
>> > mistake I make?
>> >
>> > Thanks
>>
>>
>> Is this what you'd like to do?
>>
>>        x = 0 : 0.1 : 6;
>>        y = 0 : 0.1 : 10;
>>        [x, y] = meshgrid (x, y);
>>        f = 2 * x .* sin(2*pi*y) + 4 * x .* cos(2*pi*y);
>>        mesh (x,y,f)
>>
>> Notice the use of ".*" instead of "*"
>
> Ok, thank you. This works. Now, after this function I try this one:
>
> f = exp(-((x .- 6 / 3)^2)) * sin(2 * pi * y / 10);
>
> Instead of ".*" it has ".-". The "A must be square" message is directed at
> the "=" sign. As far as I can see from the docs, this function should be no
> problem. What could be wrong here?
>
> Thank you.

f = exp(-((x - 6 / 3).^2)) .* sin(2 * pi * y / 10)