Why creating cell then it become table.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2021년 6월 21일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!