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

11 次查看(过去 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 CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by