help-octave
[Top][All Lists]
Advanced

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

Re: Multiply some colums, discarding others


From: Ron.Simonson
Subject: Re: Multiply some colums, discarding others
Date: Tue, 24 Nov 2009 12:15:15 -0800
User-agent: Thunderbird 2.0.0.19 (X11/20081209)

Good afternoon Renato,  The approach I would take to your
problem is as follows:

# Matrix A is "freq", "impedance" and "phase", like this:

# properly define the Matrix A
A = [20.66, 12.32, 49.63;
     21.47, 13.75, 48.86;
     22.30, 15.92, 47.71;
     23.17, 18.43, 45.06;
     24.07, 22.61, 39.76];

# I would like to get another Matrix, B, with the result of
# multiplication of "impedance" and "phase":
#
#       A(1,2) * cos(A(1,3)
#       A(2,2) * cos(A(2,3))
#       A(3,2) * cos(A(3,3))
#       A(4,2) * cos(A(4,3))
#       A(5,2) * cos(A(5,3))
#
#
# Matrix "B" =
#
#       20.66      A(1,2) * cos(A(1,3))
#       21.47      A(2,2) * cos(A(2,3))
#       22.30      A(3,2) * cos(A(3,3))
#       23.17      A(4,2) * cos(A(4,3))
#       24.07      A(5,2) * cos(A(5,3))

freq = A(:,1);      # extract column 1 data into freq vector
impedance = A(:,2); # extract column 2 data into impedance vector
phase = A(:,3);     # extract column 3 data into phase vector

B = [freq impedance .* cos(phase)]; # generate desired B matrix
B
clear freq impedance phase; # scuttle freq, impedance, and phase vectors
# clearing variables helps to recover memory when needed

Though not efficient in terms of storage and likely speed, extracting
the data into named variables helps me to keep track of what each
variable is.  I am not an expert by any means.

Thanks to all the expert users/programmers on this list for all the
help I have gleaned from your posts.  I store away so many of your
suggestions and hints that I am actually able to use octave for most
of my data analysis needs.  A very special thanks to Professor Eaton.

Talk to you later.  Ron.


reply via email to

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