how to Insert cell array into a cell?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hey guys, i need help inserting a cell array into a cell in another cell array. My problem has the form of this:
%INPUT
A = {'one''two''three'};
B = {'four''five''six'};
B{1,1} = A{1,:}
%WANTED OUTPUT
B = {'one''two''three'},{'five'},{'six'}
I really hope someone can help
採用された回答
VBBV
2022 年 11 月 11 日
%INPUT
A = {'one''two''three'};
B = {A,'four''five''six'};
7 件のコメント
VBBV
2022 年 11 月 11 日
%INPUT
A = {'one''two''three'};
B = {{'four'},{'five'},{'six'}}
B = 1×3 cell array
{1×1 cell} {1×1 cell} {1×1 cell}
B = {A,B} % do you mean this ?
B = 1×2 cell array
{1×1 cell} {1×3 cell}
Tobias Egebjerg
2022 年 11 月 11 日
The thing is i want A, B to change in a loop, so i want them to be like this.
D = 1
C = num2str(D)
A = {'one'C 'three'};
B = {'one''two''three'};
C = num2str()
For i in range n
print(B)
D = D+1
C = num2str(D)
A = {'one'C 'three'};
B{1,1} = A
B = [B,A]
%Output
B = {'one'}{'two'}{'three'}
B = {'one'}{C}{'three'}{'one'}{C}{'three'}
B = {'one'}{C}{'three'}{'one'}{C}{'three'}{'one'}{C}{'three'}
.
.
B = {'one'}{C}{'three'} {'one'}{C}{'three'} {'one'}{C}{'three'} ....
VBBV
2022 年 11 月 11 日
D = 1;
C = num2str(D);
A = {'one',C, 'three'};
B = {{'one'},{'two'},{'three'}};
B{1,1} = A ;
n = 10;
for i = 1:n
D = D+1;
C = num2str(D);
A = {{'one'},{C}, {'three'}};
B{i} = {B,A}
end
B = 1×3 cell array
{1×2 cell} {1×1 cell} {1×1 cell}
B = 1×3 cell array
{1×2 cell} {1×2 cell} {1×1 cell}
B = 1×3 cell array
{1×2 cell} {1×2 cell} {1×2 cell}
B = 1×4 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
B = 1×5 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
B = 1×6 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
B = 1×7 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
B = 1×8 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
B = 1×9 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
B = 1×10 cell array
{1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell} {1×2 cell}
Tobias Egebjerg
2022 年 11 月 11 日
It seems like all the strings are lost, is that right ?
Stephen23
2022 年 11 月 11 日
"It seems like all the strings are lost, is that right ? "
I doubt that. How did you check that the strings are "lost" ?
Tobias Egebjerg
2022 年 11 月 11 日
@Stephen23 I ran the script and it only creates empty cell arrays.
Stephen23
2022 年 11 月 11 日
D = 1;
C = num2str(D);
A = {'one',C, 'three'};
B = {{'one'},{'two'},{'three'}};
B{1,1} = A ;
n = 10;
for i = 1:n
D = D+1;
C = num2str(D);
A = {{'one'},{C}, {'three'}};
B{i} = {B,A};
end
B{:}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×4 cell} {1×3 cell}
ans = 1×2 cell array
{1×5 cell} {1×3 cell}
ans = 1×2 cell array
{1×6 cell} {1×3 cell}
ans = 1×2 cell array
{1×7 cell} {1×3 cell}
ans = 1×2 cell array
{1×8 cell} {1×3 cell}
ans = 1×2 cell array
{1×9 cell} {1×3 cell}
B{1}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
B{1}{1}{:}
ans = 1×3 cell array
{'one'} {'1'} {'three'}
ans = 1×1 cell array
{'two'}
ans = 1×1 cell array
{'three'}
B{1}{2}{:}
ans = 1×1 cell array
{'one'}
ans = 1×1 cell array
{'2'}
ans = 1×1 cell array
{'three'}
What exactly do you mean by "lost" ?
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Acquisition Using Any Hardware についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
