add zero elemant inside cell

1 回表示 (過去 30 日間)
NA
NA 2019 年 3 月 22 日
編集済み: Stephen23 2019 年 3 月 22 日
A={[95],[112],[98],[84],[69],[121],[108]};
B={[1,2,4],[4,3],[6,9,98],[3,7,88],[2,9,1],[55,7],[1,4],[0],[0]};
if size(A,2)<size(B,2)
% add zero at the end of A
end
I want that size of A and B should be the same
result should be
A={[95],[112],[98],[84],[69],[121],[108],[0],[0]};

採用された回答

Stephen23
Stephen23 2019 年 3 月 22 日
編集済み: Stephen23 2019 年 3 月 22 日
Simple indexing does exactly what you need:
>> A={[95],[112],[98],[84],[69],[121],[108]};
>> B={[1,2,4],[4,3],[6,9,98],[3,7,88],[2,9,1],[55,7],[1,4],[0],[0]};
>> A(end+1:numel(B)) = {[0]};
>> B(end+1:numel(A)) = {[0]};

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by