Need a piece of code to

How can I conver a n-by-n integer matrix generated in MATLAB like the below 3-by-3 matrix
A=[1 2 3
4 5 6
7 8 9];
to the form below:
B=[[1,2,3],[4,5,6], [7,8,9]]
Please help me on writing this for a n-by-n matrix.

Réponses (1)

madhan ravi
madhan ravi le 9 Juin 2019

0 votes

B = num2cell(A,2).'

5 commentaires

Hossein
Hossein le 9 Juin 2019
It's not working!
madhan ravi
madhan ravi le 9 Juin 2019
Why?!
Hossein
Hossein le 9 Juin 2019
I need to see the exact output like below
B=[[1,2,3],[4,5,6], [7,8,9]]
so I can use it in another software.
madhan ravi
madhan ravi le 9 Juin 2019
B=[[1,2,3],[4,5,6], [7,8,9]]
% copy it and paste it in MATLAB’s command window and see what happens , perhaps you are thinking of python’s list?
Hossein
Hossein le 10 Juin 2019
My original matrix is of high dimension so I need a code written for n-by-n. Then I need to see exactly something like
B=[[1,2,3],[4,5,6], [7,8,9]]
as output so I can use it in my python code.

Connectez-vous pour commenter.

Catégories

Tags

Question posée :

le 9 Juin 2019

Commenté :

le 10 Juin 2019

Community Treasure Hunt

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

Start Hunting!

Translated by