Converting a rigid3d array into a table type
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nivesh Gadipudi
le 21 Jan 2021
Réponse apportée : Mohammad Hussein Yoosefian Nooshabadi
le 12 Avr 2021
Lets's Consider a rigid3d array of 1xn array containing T, Rotational, Translational elements. I want to convert this into a table format with Location and orientation columns as shown in the figure. The output should something look like a dictionary in python with varying array dimensions for each key. However in matlab its only permitting with same number of columns array. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/495763/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/495763/image.png)
0 commentaires
Réponses (2)
Nitin Kapgate
le 9 Fév 2021
If you execute the following code, the error "All table variables must have the same number of rows." is thrown in MATLAB.
viewIds = [1:10]';
a = zeros(5,3);
b = zeros(6,10);
t1 = table(viewIds, repmat(a,10,1), repmat(a,10,1));
This is because the MATLAB expects all table variables to have the same number of rows.
To overcome this problem, you can wrap the data in a cell and then add it to the table, as demonstrated in the following code:
viewIds = [1:10]';
c = {zeros(5,3)};
d = {zeros(6,10)};
t2 = table(viewIds, repmat(c,10,1), repmat(d,10,1));
The table t2 is created succesfully now.
0 commentaires
Voir également
Catégories
En savoir plus sur Numeric Types dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!