Create table where user can input data in App Designer

I am a civil engineering student at ASU, in Arizona. I'm working on a code that predict viscoelastic response to some defined excitations. Now I want to Design an App by using App Designer in Matlab.
The app will require user to enter 3 parameters for each element used in the response model. I've been trying to get that from an editable table of size (n,3), where n is the 'number of elements', which is also a user input.
Editable table might not be the right tool but i only need a matrix of (n,3) from user input. Below is what I did but the zeros are irreplaceable.
% Callback function: LoadButton, UITable
function UITableCellEdit(app, event)
n = app.NumberofElementsEditField.Value;
dt = zeros(n,3,"double");
app.UITable.Data= dt;
end

 Accepted Answer

You need to tell the App designer that you want which columns to be editable.

6 Comments

I have that done but whatever i enter revert to '0'. See the code and the attached snip. Thanks for the feedback
% Callback function: LoadButton, UITable
function UITableCellEdit(app, event)
n = app.NumberofElementsEditField.Value;
dt = zeros(n,3,"double");
app.UITable.Data= dt;
load = app.LoadingTypeDropDown.Value;
if strcmp(load,'Relaxation')
app.UITable.ColumnName(1) = {'E'};
else
app.UITable.ColumnName(1) = {'J'};
end
end
% Display data changed function: UITable
function UITableDisplayDataChanged(app, event)
indices = event.Indices;
NewData = event.NewData;
end
Why do you have these lines here
dt = zeros(n,3,"double");
app.UITable.Data= dt;
They are converting every element back to zero.
So, i only want to create a table where the user can enter inputs.
How do I get 'n' number of rows depending on the user's input.
Ok, I am a bit confused. I now noticed that the code which you pasted was a callback for an edit field. Why did you also make the same function a callback for uitable? The two lines are correct, but you should remove this function as callback for uitable and the app should work fine.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!