Extracting UITable data for statistical analysis in the app designer

Hi
In my app designer app, I can get my data from pressing a button as a Table and export tha table to excel for each column. If I have multiple attempts by using the same button, I will get raw data for each pressing. I want to calculate average and Standard deviation of each column and desplay it on EditField as a value (from all rows). This is my code:
I used
Ave = mean(app.UITable.Data{1,1});
but I know {1,1} only get the first row of the first column. I also used (:,1) and {:,1} but none of them worked. I appreciate for any help!?
----------------------------------------------------------------------------------------------
%Button Name: Show Data%
% Button pushed function: ShowDataButton
function ShowDataButtonPushed(app, event)
app.UITable.Data; %my UITable with 3 column and rows%
Ave = mean(app.UITable.Data{1,1}); %calcualte mean value of the first column%
app.MeanRTEditField.Value = Ave; %Dispaly the Mean value%

Answers (1)

This worked for me
function ButtonPushed(app, event)
app.UITable.Data = rand(200,4);
app.EditField.Value = mean(app.UITable.Data(:,1));
app.EditField2.Value = std(app.UITable.Data(:,1));
end

5 Comments

Thanks for your answer. This method works if I put random numbers same as you, but it gives me error messages when I use my table:
app.UITable.Data = tab; %tab is my UITable name%
Can you post what your table data is? Or post something that is representative.
I attached 2 pictures from the code. I will add row to the unitabel after each pushbutton press.
Using 'app.tab' alone or as 'app.tab=app.UITable.Data' does not matter. There are 3 columns in the table and I want mean,SD for the toc column.
my table data is numeric (1.25, etc.) and time format (HH:mm:SS.mmm) but I want to extract only the numeric column (RT).

Sign in to comment.

Categories

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

Products

Release

R2022b

Asked:

Mo
on 15 Jan 2023

Commented:

Mo
on 18 Jan 2023

Community Treasure Hunt

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

Start Hunting!