Error: No constructor 'mlreportgen.dom.Number' with matching signature found
9 ビュー (過去 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.
0 件のコメント
回答 (1 件)
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.
参考
カテゴリ
Help Center および File Exchange で MATLAB Report Generator についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!