got error Undefined function 'mpower' for input arguments of type 'table'.

1 回表示 (過去 30 日間)
Khairul nur
Khairul nur 2021 年 2 月 15 日
コメント済み: Cris LaPierre 2021 年 2 月 15 日
I have this code, i had run using dummy data run smoothly. However has error in real data.
for c1=i:loop_col_utk_data
j=1
for c2=j:noofrow_centroid %run no of row
noofrow_centroid
hasiltambah=0
while j<=noofrow_centroid %counter the row, freez the col
nilai1=centroid(j,i)%ambildata
nilai2=centroid(j,noofcol_centroid_innerloop)%ambil centroid
hasil_atas=nilai1*(nilai2^2)
hasiltambah_atas=hasiltambah_atas+(nilai1*(nilai2^2))
hasil_bawah=nilai2^2
hasiltambah_bawah=hasiltambah_bawah+(nilai2^2)
valueMean(j,k) = hasil_bawah
j=j+1
end
end
something wrong of ^2, please explain to me what is going wrong and how i can fix this?
Undefined function 'mpower' for input arguments of type 'table'.
Error in kirapercluster (line 23)
hasil_atas=nilai1*(nilai2^2)

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 2 月 15 日
You must be passing in a table data type, but mpower only accepts array. See this page on how to access data in a table. Use one of the options that returns an array.
Here, it appears that centroid is a table. When you use parentheses with a table, the result is also a table. Use curly braces instead to create nilai1 and nilai2.
nilai1=centroid{j,i}%ambildata
nilai2=centroid{j,noofcol_centroid_innerloop}%ambil centroid
  2 件のコメント
Khairul nur
Khairul nur 2021 年 2 月 15 日
still something wrong as below error:
Undefined function 'mtimes' for input arguments of type 'cell'.
Error in kirapercluster (line 23)
hasil_atas=nilai1*(nilai2^2) %has error in ^ when using real data
edited code
for c1=i:loop_col_utk_data
j=1
for c2=j:noofrow_centroid %run no of row
noofrow_centroid
hasiltambah=0
while j<=noofrow_centroid %counter the row, freez the col
nilai1=centroid{j,i}%ambildata
nilai2=centroid{j,noofcol_centroid_innerloop}%ambil centroid
hasil_atas=nilai1*(nilai2^2)
hasiltambah_atas=hasiltambah_atas+(nilai1.*(nilai2^2))
hasil_bawah=nilai2^2
hasiltambah_bawah=hasiltambah_bawah+(nilai2^2)
valueMean(j,k) = hasil_bawah
j=j+1
end
end
Cris LaPierre
Cris LaPierre 2021 年 2 月 15 日
How do you create centroid? It is apparently a table of cells.
The good news is you have gotten past the first problem successfully.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by