For Programmers: Free Programming Magazines  


Home > Archive > Matlab > June 2007 > symbolic vector multiplication









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author symbolic vector multiplication
junkyard@jaggerdog.com

2007-06-29, 7:14 pm

Hello,

I am new to the symbolic math toolbox, and I have a question regarding
vector multiplication. Suppose I have

syms a b c
f = a*b*c

if I want to evaluate this for the case where a and b are 1-D vectors
(for example, a = (1:10), b = 3*(1:10)) and c
is a scalar, how can I do this?

(If I were doing it staight from matlab, I would use: f = a.*b.*c, but
the symbolic expression won't let me use the . for array
multiplication)

If I try:
subs(f, {a,b,c},{(1:10),3*(1:10),4), I get the error message:
"Elements of the substitution cell array must be of the same size"

If I try:
a = (1:10)
b = 3*(1:10)
c = 4

eval(f)

I get the error message: "Inner matrix dimensions must agree."

if I transpose b and try it again, it works, but it has done matrix
multiplication, leaving me with a single value, not a vector result.

Is there a way to do this? Or, more specifically, is there a way to
do this that doesn't require looping through the vector elements?

thanks,
melissa

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com