Union two matrix of nxn, how?

4 ビュー (過去 30 日間)
M Adli Hawariyan
M Adli Hawariyan 2022 年 11 月 18 日
回答済み: Eric Delgado 2022 年 11 月 18 日
i have a data like this
mdfl_dc_1 =...
[85 97 109 121 133 145 157 169 181
43 0 0 0 33 0 0 0 0
22 0 0 0 122 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0]
mdfl_ic_1 =
85 97 109 121 133 145 157 169 181
60 0 0 0 0 0 0 0 0
55 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
i want to union this two matrices in the shape on (...,1) and after that i want to remove zero value. how to do this?

採用された回答

Eric Delgado
Eric Delgado 2022 年 11 月 18 日
Try this...
mdfl_dc_1 = [85 97 109 121 133 145 157 169 181; ...
43 0 0 0 33 0 0 0 0; ...
22 0 0 0 122 0 0 0 0; ...
0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0];
mdfl_ic_1 = [85 97 109 121 133 145 157 169 181; ...
60 0 0 0 0 0 0 0 0; ...
55 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0];
MDFL = [reshape(mdfl_dc_1, [numel(mdfl_dc_1), 1]); ...
reshape(mdfl_ic_1, [numel(mdfl_ic_1), 1])];
MDFL = MDFL(MDFL~=0)
MDFL = 24×1
85 43 22 97 109 121 133 33 122 145

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by