New Matrix with vector addition on diagonal - MATLAB Cody - MATLAB Central

Problem 44740. New Matrix with vector addition on diagonal

Difficulty:Rate

consider 2 vectors

x=[1 2 3]
y=[4 5 6]

then generate a new Matrix, where Addition of x & y will be diagonal Elements of the new Matrix. i.e. new Matrix will have x+y=[5 7 9] as diagonal Elements

Output =[5     6     7
         6     7     8
         7     8     9]

Solution Stats

56.99% Correct | 43.01% Incorrect
Last Solution submitted on May 07, 2025

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers46

Suggested Problems

More from this Author4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!