Creating 3D array from 2D with increment
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jiayun Liu
am 13 Okt. 2022
Kommentiert: Jiayun Liu
am 13 Okt. 2022
Suppose I have a 2D array of integers A and I want to create another 2D array B = A+1 and I want to combine them into 1 3D array. I will do something like cat(3,A,B). Now I want to add another 2D array C = B+1 to it. The simple way I can think of would be to loop it through a for loop. I was wondering if there are any other way of doing this without using for loop.
0 Kommentare
Akzeptierte Antwort
Chunru
am 13 Okt. 2022
A = randi([1, 10], [3, 5])
C = A + reshape(0:2, [1,1,3]) % increment 0, 1, 2 for example
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!