Why creating cell then it become table.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a main n a function. This is the main:
k=3;
data=[2,1;2,4;5,3;3,3;4,3;1,3;1,1;1,2;4,2;5,2];
noofrow=10;
pm=[4.46548518703744e-13,0.999999999972956,2.65973210752259e-11;0.999999999721704,2.76819651086087e-10,1.47632293709860e-12;0.999999905913871,9.40858876460889e-08,2.41912087988739e-13;1.30415928862666e-20,3.82843279259685e-16,1.00000000000000;1.50904190683861e-09,2.27976771986804e-08,0.999999975693281;1.48213530202206e-09,0.0160961639229467,0.983903834594918;1.95427183156120e-14,4.26017383695369e-12,0.999999999995720;0.999999999993147,6.85195488054645e-12,1.12188335455077e-15;0.999999999999519,4.77821392183546e-13,3.10108174121301e-15;1.13939214498226e-07,0.999999885823348,2.37437863835418e-10];
display_centroid(pm,k,data,noofrow)
This is the function:
function[]= display_centroid(pm,k,data,noofrow)
transpose_pm=pm.'
maxU = max(transpose_pm)
index = cell(k,1)
for i=1:k
index{i}= find(transpose_pm(i,:) == maxU)
end
disp(index)
I had created the index as cell. While looping the index still in cell. However when the end of loop. The cell become table as below:
{1×4 double}
{1×2 double}
{1×4 double}
[1×4 double]
[1×2 double]
[1×4 double]
i need it to be maintain as cell as needed in my further coding. Please help me to understand this and also how i want to be the index in cell. TQIA
0 commentaires
Réponses (1)
Walter Roberson
le 21 Juin 2021
I do not see any table. Which MATLAB release are you using?
k=3;
data=[2,1;2,4;5,3;3,3;4,3;1,3;1,1;1,2;4,2;5,2];
noofrow=10;
pm=[4.46548518703744e-13,0.999999999972956,2.65973210752259e-11;0.999999999721704,2.76819651086087e-10,1.47632293709860e-12;0.999999905913871,9.40858876460889e-08,2.41912087988739e-13;1.30415928862666e-20,3.82843279259685e-16,1.00000000000000;1.50904190683861e-09,2.27976771986804e-08,0.999999975693281;1.48213530202206e-09,0.0160961639229467,0.983903834594918;1.95427183156120e-14,4.26017383695369e-12,0.999999999995720;0.999999999993147,6.85195488054645e-12,1.12188335455077e-15;0.999999999999519,4.77821392183546e-13,3.10108174121301e-15;1.13939214498226e-07,0.999999885823348,2.37437863835418e-10];
display_centroid(pm,k,data,noofrow)
function[]= display_centroid(pm,k,data,noofrow)
transpose_pm=pm.';
maxU = max(transpose_pm);
index = cell(k,1)
for i=1:k
index{i}= find(transpose_pm(i,:) == maxU);
end
disp(index)
end
0 commentaires
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!