Replace initial values of an matrix.

1 回表示 (過去 30 日間)
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 11 月 26 日
コメント済み: Ricardo Gutierrez 2019 年 11 月 27 日
Hi. Good day.
Waiting for your valuable help.
I have a matrix A (4 X 4) with these initial values
A = [0.3511 1.2091 1.8834 1.5089
     0.5290 1.1016 1.7171 1.2664
     0.9242 1.5412 1.8093 1.0313
     0.5027 1.4695 2.2388 1.1906];
Matrix A is subjected to several mathematical steps and as a result a matrix B is obtained (3 X 4)
B = [0.3512 1.2999 1.8885 1.5588
     0.5299 1.1999 1.9192 1.2787
     0.9292 1.5888 1.8993 1.2589];
It is observed that matrix B is missing a line to be the same size as matrix A
How do I replace the values of matrix B in matrix A by repeating the last line of matrix B?
The new matrix A would look like this
B = [0.3512 1.2999 1.8885 1.5588
     0.5299 1.1999 1.9192 1.2787
     0.9292 1.5888 1.8993 1.2589
     0.9292 1.5888 1.8993 1.2589];

採用された回答

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 11 月 26 日
編集済み: JESUS DAVID ARIZA ROYETH 2019 年 11 月 26 日
solution in general:
B=B(horzcat(1:size(B,1),repmat(size(B,1),1,size(A,1)-size(B,1))),:)
particular:
B=B([1:3 3],:)
  1 件のコメント
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 11 月 27 日
Excellent !!!
It worked.
Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by