combining and separating two matrices

1 回表示 (過去 30 日間)
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 24 日
コメント済み: Berfin Çetinkaya 2022 年 3 月 24 日
I have two matrices
A matrix:
1 2 4
7 5 3
9 5 1
B matrix:
3 8 4
5 4 2
8 3 6
I want to combine them like this.
D matrix:
1-3 2-8 4-4
7-5 5-4 3-2
9-8 5-3 1-6
Note : (The - sign I put in is meaningless. It can be different signs or spaces.)
And can I separate these matrices again after writing them in the same cell?
Thank you for help
  2 件のコメント
John D'Errico
John D'Errico 2022 年 3 月 24 日
You seem to be asking elementary questions about MATLAB. Perhaps you really just need to be doing the Onramp tutorials? That is, learn basic MATLAB?
Do you want to create the character strings as elements, thus '1-2', or the result of that operation, that is the number 3?
Once you create a result as a number, of course you cannot undo the operation. If you will leave them as strings, then of course you can. You need to learn to work with the tools of MATLAB that can operate on strings.
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 24 日
I want it to stay as a string So I want it to stay 1-2.
I don't have deep knowledge in matlab but I need to use it in a project. And where I hang out, what I find on the internet doesn't work for me. So I would be glad if you could help me.

サインインしてコメントする。

採用された回答

KSSV
KSSV 2022 年 3 月 24 日
A = [1 2 4
7 5 3
9 5 1] ;
B =[3 8 4
5 4 2
8 3 6] ;
D = cell(3,3) ;
for i = 1:3
for j = 1:3
D{i,j} = [num2str(A(i,j)),'-',num2str(B(i,j))] ;
end
end
D
D = 3×3 cell array
{'1-3'} {'2-8'} {'4-4'} {'7-5'} {'5-4'} {'3-2'} {'9-8'} {'5-3'} {'1-6'}

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by