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

11 visualizaciones (últimos 30 días)
RGB85
RGB85 el 23 de En. de 2024
Comentada: RGB85 el 30 de En. de 2024
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.

Respuestas (1)

Varun
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.
  1 comentario
RGB85
RGB85 el 30 de En. de 2024
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.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by