Error: No constructor 'mlreportgen.dom.Number' with matching signature found
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Varun
el 30 de En. de 2024
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.
Ver también
Categorías
Más información sobre MATLAB Report Generator en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!