Adding a cell to another cell in a specific position
1 次查看(过去 30 天)
显示 更早的评论
I have two cells:
A(n x 1)
B(m x 1)
I'd like to add cell B to cell A in a specific position of A.
Do you have any suggestion?
0 个评论
采纳的回答
Rik
2021-3-29
What do you mean exactly by adding?
%create some data
n=3;m=5;
A=num2cell(1:n).';
B=num2cell(2*n+(1:m)).';
%option 1:
A1=A;
A1{2}=B;
disp(A1)
%option 2:
k=2;A2=A;
A2=[A2(1:k);B;A2((k+1):end)];
disp(A2)
2 个评论
Rik
2021-3-29
If my answer solved your issue, please consider marking it as accepted answer. If not, feel free to comment with your remaining questions.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!