I am trying to simplify my code a bit, and I am across a small question. Let
v = [1; 2; 3];
a1 = [4; 5; 6];
a2 = [7; 8; 9];
A = [a1, a2];
I am aiming to compute
u = [v.*a1, v.*a2]
by only using v one time. Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
yes, you can do this using
bsxfun, for example:or also by using
repmator also by using
kronor last, just using matrix multiplication:
I’m sure there are even more ways, but I’ll stop here…