use the mat2cell function

8 visualizzazioni (ultimi 30 giorni)
zhengyang shang
zhengyang shang il 23 Mar 2021
Risposto: Star Strider il 23 Mar 2021
Now i have a 5*100 matrix, how to convert it to a 5*10 cell and each cell contain 1*10?

Risposte (2)

David Hill
David Hill il 23 Mar 2021
b=mat2cell(a,[1 1 1 1 1],[[10 10], [10 10], [10 10], [10 10], [10 10]]);

Star Strider
Star Strider il 23 Mar 2021
Try this:
A = randi(9, 5, 100); % Create Matrix To Test Code
C = mat2cell(A, ones(5,1), ones(1,10)*10) % Desired Result
.

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by