How do I save the calculated data in the GUI and output it as a table?

2 Ansichten (letzte 30 Tage)
Hello
I am trying to make (what I thought would be) a simple and quick to make GUI for assigning values to audio processings.
What I am curious about is transferring the data created in the button callback function to the uitable.
The code I used is below.
function fittingbutton_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Frequency_Data = [160 200 250 315 400 500 630 800 1000 1250 1600 2000 2500 3150 4000 5000 6300 8000];
Gain_Data1 = fillmissing(FIG_gain(2,Data,1),'constant',0);
Gain_Data2 = fillmissing(FIG_gain(2,Data,2),'constant',0);
Gain_Data3 = fillmissing(FIG_gain(2,Data,3),'constant',0);
Gain_Data = vertcat(Frequency_Data,Gain_Data1,Gain_Data2,Gain_Data3);
set(handles.uitable2,'Enhanced FIG6 Parameter Table', array2table(Gain_Data));
%set(handles.uitable2,'Data', Gain_Data);
end
This code does not work, and the method of saving and loading data in Excel (ex : xlswrite, xlsread) or assignin function, but it didn't work.
I want the calculated Gain_Data(4 by 18 Array) values ​​to be output to the uitable when the fitting button is pressed.
I've spent a lot of time trying to use this method, but I can't seem to get it to work, so I'm asking for help.
Any help would be greatly appreciated, Thank you.

Antworten (1)

Abhishek Chakram
Abhishek Chakram am 26 Sep. 2023
Hi 형일 ,
It is my understanding that you are facing difficulty in storing the calculated values and displaying it in a table. In your program, you can define a property variable and assign the calculated values to it. When the fitting button is tapped, you can use the same property to set it to the table.
Here are the steps for the creating a property:
  1. Open your App Designer project in MATLAB.
  2. Click on the "Code View" button to switch to the code editor.
  3. In the left pane, go to the Properties section
  4. Click on Add and rename the property accordingly
  5. Save your changes.
Here’s a sample code for the same:
properties (Access = private)
tableData % Description
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CalculateButton
function CalculateButtonPushed(app, event)
matrix = reshape(1:56, 7, 8);
app.tableData = matrix;
end
% Button pushed function: FittingButton
function FittingButtonPushed(app, event)
app.UITable.Data = app.tableData;
end
end
In this example, the tableData is a property created to store the calculated values which is later used as app.UiTable.Data when FittingButtonPushed Callback is executed.
Best Regards,
Abhishek Chakram

Kategorien

Mehr zu Environment and Settings 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