help-octave
[Top][All Lists]
Advanced

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

Re: Trying to avoid loops when adjusting two variables.


From: Jordi Gutierrez Hermoso
Subject: Re: Trying to avoid loops when adjusting two variables.
Date: Tue, 17 Apr 2007 09:31:55 -0500

On 17/04/07, Harbinson, Jeremy <address@hidden> wrote:
More complicated case (the one for which I would like to avoid a for loop):

I now have 2 vectors A and B and a function with two variables (eg y=z*x^2).
I want to apply the function to both A and B, using B for variable z and A
for variable x, and get an output which is a grid within which each element
is the result of applying the function to a particular pair of elements from
A and B.

Do [AA,BB] = meshgrid(A,B); then AA and BB contain the grid you want,
and you can do YY = AA.*BB.^2.

HTH,
- Jordi G. H.


reply via email to

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