Can't show values to GUI table

1 次查看(过去 30 天)
Adryan Fauzi
Adryan Fauzi 2023-7-5
评论: Rik 2023-7-5
I did a first-order statistical calculation and I want to display the value I got in the gui table that I created with the resultTable tag, but the results of the calculation cannot appear in the table. here is the code i have made:
% Menghitung fitur statistik orde pertama
eeg_signal = randn(1, 1000); % Contoh sinyal EEG acak sepanjang 1000 data
% Menghitung fitur statistik orde pertama
mean_value = mean(eeg_signal); % Rata-rata
std_value = std(eeg_signal); % Standar deviasi
skewness_value = skewness(eeg_signal); % Skewness
kurtosis_value = kurtosis(eeg_signal); % Kurtosis
% Menampilkan hasil pada tabel GUI
data = {'Mean', mean_value; 'Standard Deviation', std_value; 'Skewness', skewness_value; 'Kurtosis', kurtosis_value};
set(handles.resultTable, 'Data', data);
Unable to resolve the name 'handles.resultTable'.
  2 个评论
Rik
Rik 2023-7-5
Why not? As you can see below, as long as handles.resultTable is a table UI component, your code should work.
handles.resultTable = uitable('Unit','Normalized','Position',[0 0 1 1]);
% Menghitung fitur statistik orde pertama
eeg_signal = randn(1, 1000); % Contoh sinyal EEG acak sepanjang 1000 data
% Menghitung fitur statistik orde pertama
mean_value = mean(eeg_signal); % Rata-rata
std_value = std(eeg_signal); % Standar deviasi
skewness_value = skewness(eeg_signal); % Skewness
kurtosis_value = kurtosis(eeg_signal); % Kurtosis
% Menampilkan hasil pada tabel GUI
data = {'Mean', mean_value; 'Standard Deviation', std_value; 'Skewness', skewness_value; 'Kurtosis', kurtosis_value};
set(handles.resultTable, 'Data', data);
Sandeep Mishra
Sandeep Mishra 2023-7-5
Can you share how you are initializing handles.resultTable?
As error suggests, it should be an UITable to work

请先登录,再进行评论。

回答(1 个)

Neev
Neev 2023-7-5
编辑:Rik 2023-7-5
Hey Adryan
I have reproduced your code to display it in a GUI Table as per your wish, you can find the code below and try running it.
This code worked on my system. The code is as follows:
% Menghitung fitur statistik orde pertama
eeg_signal = randn(1, 1000); % Contoh sinyal EEG acak sepanjang 1000 data
% Menghitung fitur statistik orde pertama
mean_value = mean(eeg_signal); % Rata-rata
std_value = std(eeg_signal); % Standar deviasi
skewness_value = skewness(eeg_signal); % Skewness
kurtosis_value = kurtosis(eeg_signal); % Kurtosis
% Menampilkan hasil pada tabel GUI
data = {'Mean', mean_value; 'Standard Deviation', std_value; 'Skewness', skewness_value; 'Kurtosis', kurtosis_value};
% Define the column names
columnNames = {'Feature', 'Value'};
% Set the data in the GUI table
set(handles.resultTable, 'Data', data);
Unable to resolve the name 'handles.resultTable'.
set(handles.resultTable, 'ColumnName', columnNames);
I got the an output as shown in below snippit.
I hope I was able to help you :)
  1 个评论
Rik
Rik 2023-7-5
@Neev, If you format your code as code, you can run it right from within the editor. That way you can show what should happen.
In this case you didn't show how you initialized the table, so the code works (or fails) exactly the same way the originally posted code does.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by