Question

x = [1 2 3 ; 5 6 7 ; 9 12 17] y = [1...

x = [1 2 3 ; 5 6 7 ; 9 12 17]
y = [1 5 8]'

XY = [x y]

XY(2,:) = XY(2,:) - 5 * XY(1,:)
XY(3,:) = XY(3,:) - 9 * XY(1,:)
XY(1,:) = 2 * XY(1,:) + XY(2,:)
XY(2,:) = 1/2 * XY(2,:)
XY(3,:) = -3 * XY(2,:) + XY(3,:)
XY(2,:) = 2 * XY(3,:) + XY(2,:)
XY(1,:) = XY(1,:) + XY(3,:)

How can i multiply last version of this matrix's all rows by 1/2? Is there any built-in ones to perform this in MATLAB

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

Use bsxfun to multiply all rows by 0.5 for last version of matrix. Add this line to last of code

XY(:,:) = bsxfun(@times, XY, [0.5; 0.5; 0.5])

Explanation:

Syntax: X=bsxfun(fun, A, B)

Description: The function applies the element-wise binary operation specified by the function handle fun to arrays A and B.

fun implies Binary function to apply where times represents Array multiplication

Add a comment
Know the answer?
Add Answer to:
x = [1 2 3 ; 5 6 7 ; 9 12 17] y = [1...
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