Union two matrix of nxn, how?

조회 수: 3 (최근 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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by