How to input strings into uitable in app designer

25 Ansichten (letzte 30 Tage)
Angela Sita
Angela Sita am 5 Feb. 2018
Beantwortet: Michael Ashcraft am 25 Apr. 2022
I am trying to create a table in an app which the user can add a text comment to. However, whenever I try to change the value of a cell, it displays NaN. I have changed the format of the column to 'char', so I am unsure what the issue is.A and B are random vectors of numbers
C=find(app.B>0.9);
L=length(C);
for i=1:1:L;
app.UITable.Data(i,1)=[i];
end
app.UITable.Data(:,2:3)=0
app.UITable.ColumnFormat(:,2)=({'char'});
app.UITable.ColumnFormat(:,3)=({'char'});
app.UITable.ColumnEditable=[false true true];
Any help would be greatly appreciated!
  3 Kommentare
Angela Sita
Angela Sita am 5 Feb. 2018
B is a property within the app
Nicolas Leclerc
Nicolas Leclerc am 3 Jun. 2020
I have the same problem, have you find a solution ?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Michael Ashcraft
Michael Ashcraft am 25 Apr. 2022
I had a similar problem occur while working on my own app. Below is my code with how I solved the issue.
app.UITable.ColumnFormat = {'char','char','numeric','numeric'};
if strcmp(app.VehicleTypeListBox.Value,'(Custom Weight)')
app.UITable.Data{1,1} = 'Custom Weight';
elseif strcmp(app.VehicleTypeListBox.Value,'SUV')
app.UITable.Data{1,1} = 'SUV';
elseif strcmp(app.VehicleTypeListBox.Value,'Pickup Truck')
app.UITable.Data{1,1} = 'Pickup Truck';
else
app.UITable.Data{1,1} = 'Sedan';
end
if strcmp(app.BrakePadMaterialDropDown.Value,'Ceramic')
app.UITable.Data{1,2} = 'Ceramic';
elseif strcmp(app.BrakePadMaterialDropDown.Value,'Semi-Metallic')
app.UITable.Data{1,2} = 'Semi-Metallic';
else
app.UITable.Data{1,2} = 'NAO (Non-Asbestos Organic)';
end
app.UITable.Data{1,3} = num2str(app.InitialSpeedMPHEditField.Value);
app.UITable.Data{1,4} = num2str(distance);
The solution I used make the table read strings also prevented the table from directly reading numbers. However, it is a lot easier to convert numbers into words, than converiing words inti numbers. I strongly encourage paying attention to the curly brackets specifying where the data goes in the table. This will not work if you use parenthesis.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by