Load output files and display file names on the uitable for file selection at app designer

8 次查看(过去 30 天)
I want to load output files to select some files to compare.
  1. First, read files like below (It was OK)
function [A D] = file_read(app);
[file_p, pathname] = uigetfile( ...
{'*.mat','MAT-files (*.mat)'},...
'Pick a file');%
load(file_p);
app.EditField.Value = file_p;
end
2. Next, I want to display selected file names on the uitable(UIFigure) to choice files for compare
I tryed like below but not found solutions yet.
function AddButtonPushed(app, event)
d_num = [];
app.d{d_num+1} = {true, app.EditField.Value} ;
uit = uitable(app.UIFigure,'ColumnWidth',{50,'auto'},'ColumnEditable',[true false]);
uit.ColumnName = {'Select','File name'};
uit.Data = app.d{:,:};
uit.ColumnSortable = true;
uit.Position = [20 20 600 250];
d_num = length(uit.Data);
end
Can I have solution ?

回答(1 个)

Ravi
Ravi 2023-10-5
Hi JH Bang,
According to my understanding, you want to select files using uitable and later want to display them in a table.
The “file_read” function will work fine here. However, for the “AddButtonPushed” method, there is a workaround for concatenating new entries to the table data. I suggest you use the following concatenation method in your “AddButtonPushed” method
newEntry = {true, app.EditField.Value};
uit.Data = [uit.Data; newEntry];
Example:
x = [1 2 3];
y = [4 5 6];
x = [x; y];
disp(x);
1 2 3 4 5 6
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by