MATLAB Answers

0

Replace Row in a Matrix with an Vector

Asked by Haocheng Du on 18 Sep 2019
Latest activity Edited by KALYAN ACHARJYA on 18 Sep 2019
I have generated a matrix M with M = magic(5), and I was asked to creat a new matrix M_new, where M_new is M with its last row replaced by a row vector. I was required to use only one line of code, so no equal signs...
Original question:
M_new = %Matrix M, but the last row is replaced by vector Row
% Hint: This can be done in one line of code

  0 Comments

Sign in to comment.

1 Answer

Answer by KALYAN ACHARJYA on 18 Sep 2019
Edited by KALYAN ACHARJYA on 18 Sep 2019

Replace Row in a Matrix with an Vector
matrix(n,:)=vector_data
n is row number, Ensured that vector_data length and row length are same

  0 Comments

Sign in to comment.