Question

Problem Summary This is a basic problem that uses a for-loop. Write a function called vector_multiply that takes two vectors
0 0
Add a comment Improve this question Transcribed image text
Answer #1
function v = vector_multiply(a, b)
    if length(a) ~= length(b)
        error('Input vectors must be the same length.')
    end
    for ii=1:length(a)
        v(ii) = a(ii) * b(ii);
    end
end

product = vector_multiply([1, 2, 3, 6], [9, 6, 4, 0]), product = 9 12 12 o

Add a comment
Know the answer?
Add Answer to:
Problem Summary This is a basic problem that uses a for-loop. Write a function called vector_multiply...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT