フィルターのクリア

Error: No constructor 'mlreportgen.dom.Number' with matching signature found

22 ビュー (過去 30 日間)
RGB85
RGB85 2024 年 1 月 23 日
コメント済み: RGB85 2024 年 1 月 30 日
I have the following code in an app to populate a table in a report template and get the following error: "No constructor 'mlreportgen.dom.Number' with matching signature found" at the line "app.data.all_S(i) = Number(cell2mat(app.UITable.Data(i,1)));"
makeDOMCompilable();
import mlreportgen.report.*
import mlreportgen.dom.*
app.data.all_S = Number();
app.data.all_C = Number();
app.data.all_k = Number();
for i = 1:6
app.data.all_S(i) = Number(cell2mat(app.UITable.Data(i,1))); %Error occurs
app.data.all_S(i).Style = {NumberFormat("%.0f")};
append(D, app.data.all_S(i));
moveToNextHole(D);
app.data.all_C(i) = Number(cell2mat(app.UITable.Data(i,2)));
app.data.all_C(i).Style = {NumberFormat("%.3f")};
append(D, app.data.all_C(i));
moveToNextHole(D);
app.data.all_k(i) = Number(cell2mat(app.UITable.Data(i,3)));
app.data.k(i).Style = {NumberFormat("%.2E")};
append(D, app.data.all_k(i));
moveToNextHole(D);
end
I have the following code in a different app that functions as intended and runs with no errors.
makeDOMCompilable();
import mlreportgen.report.*
import mlreportgen.dom.*
app.data.all_L = Number();
app.data.all_T = Number();
for i = 1:length(app.data.Force)
app.data.all_L(i) = Number(cell2mat(app.UITable.Data(i,2)));
app.data.all_L(i).Style = {NumberFormat("%.2E")};
append(D, app.data.all_L(i));
moveToNextHole(D);
app.data.all_T(i) = Number(cell2mat(app.UITable.Data(i,3)));
app.data.all_T(i).Style = {NumberFormat("%.2E")};
append(D, app.data.all_T(i));
moveToNextHole(D);
end
The first block of code in the new app was copy/paste/edit from the bottom block. I can't figure out why one generates an error and the other does not.

回答 (1 件)

Varun
Varun 2024 年 1 月 30 日
Hi RGB85,
Looks like you are facing an error “No constructor 'mlreportgen.dom.Number' with matching signature found" and you have copy-pasted and edited the code form bottom block.
It seems like you have defined “app.data.all_k = Number();” and using it as follows:
app.data.all_k(i) = Number(cell2mat(app.UITable.Data(i,3)));
app.data.k(i).Style = {NumberFormat("%.2E")};
But, it you notice you have incorrectly used “app.data.k(i).Style”. You should instead use it as “app.data.all_k(i).Style = {NumberFormat("%.2E")};”.
To learn more about using “uitable”, please refer to the following documentation:
Hope it helps.
  1 件のコメント
RGB85
RGB85 2024 年 1 月 30 日
Thanks for your suggestion. You are correct that I have a typo in the "app.data.k" line, but the error occurs in the line:
app.data.all_S(i) = Number(cell2mat(app.UITable.Data(i,1)));
so I never actually make it to the line with the typo. I don't think that solves my error, but I appreciate you taking the time to respond.

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

カテゴリ

Help Center および File ExchangeMATLAB Report Generator Task Examples についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by