help-octave
[Top][All Lists]
Advanced

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

Re: Vectorize Problem


From: Jordi Gutiérrez Hermoso
Subject: Re: Vectorize Problem
Date: Sun, 27 Feb 2011 19:32:19 -0600

 On 27 February 2011 17:12, Thomas D. Dean <address@hidden> wrote:
> I have an array from a CNC application
>
> octave: 1> V
>   0.00000  -0.18000
>  -0.52500   0.00000
>   0.00000   0.18000
>   0.52500   0.00000
>
> I want to derive hand-wheel rotations:
>  V(:,1) is x hand-wheel
>  V(:,2) is y hand-wheel
>
> If V(1,1) < 0 then "X CW"
>          > 0 then "X CCW"
>         == 0 then ""
> If V(1,2) < 0 then "Y CW"
>          > 0 then "Y CCW"
>         == 0 then ""

I don't know if I really understand your problem, but I think it can
be as simple as this, using cell arrays:

   ## Create some random V...
   V = rand(100,2) - 0.5;
   V(abs(V) < 0.2) = 0;

   ## Create a cell containing strings that describe the rotations
   C = cell(size(V));

   ## Populate the cell
   C(V(:,1) < 0, 1) = "X CW";
   C(V(:,1) > 0, 1) = "X CCW";
   C(V(:,2) < 0, 2) = "Y CW";
   C(V(:,2) > 0, 2) = "Y CCW";

HTH,
- Jordi G. H.


reply via email to

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