add cell to arraycell
4 ビュー (過去 30 日間)
古いコメントを表示
i want to add sistema to oldList but i reveive error
newList=[{sistema} oldList];
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
0 件のコメント
回答 (2 件)
Milan Bansal
2024 年 7 月 20 日
編集済み: Milan Bansal
2024 年 7 月 20 日
Hi Luca Re,
I understand that you wish to add a new row in the cell array "oldList" whole first element is "sistema" but are facing issues with it.
The variable "oldList" in the attached .MAT file is a cell array with 3 rows and 15 columns, where as the variable "sistema" is just a string. Hence concatenating them directly is not possible due to inconsistent dimensions. However you can add the "sistema" in the "oldList" in a new row as shown in the code snippet below:
load("matlab_cell.mat")
newRow = cell(1, 15);
newRow{1, 1} = sistema;
% Concatenate newRow with oldList to create newList
newList = [newRow; oldList]
Hope this helps!
LeoAiE
2024 年 7 月 20 日
Not sure if I understand your question here but I think you can do this:
oldList = {struct('field1', 1), struct('field1', 2)};
sistema = struct('field1', 3);
% Convert sistema to a cell and concatenate
newList = [{sistema}, oldList];
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Software Development Tools についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!