load mat table to gui table

2 views (last 30 days)
Yusran Said
Yusran Said on 17 Aug 2017
Commented: Yusran Said on 17 Aug 2017
hello, i need to load specific data from my mat file to gui table u can see mat file in the picture https://www.mathworks.com/matlabcentral/answers/uploaded_files/85736/image.png i need to show specific data,
load Data_Plat.mat
[row,~] = size(Database_All);
data2 = cell(row,4);
for n = 1:row
data2{n,1} = Database_All.Plat{n};
data2{n,2} = Database_All.Nama{n};
data2{n,3} = Database_All.Jurusan{n};
data2{n,4} = Database_All.Status{n};
end
set(handles.uitable1,'Data',data2);
this is my code for show all data from mat file in to gui table, the question is, how can i just show 1 data, for example, data with number plat DD6713MT

Accepted Answer

Guillaume
Guillaume on 17 Aug 2017
Firstly, a much simpler version of your original code:
data_plat = load('Data_Plat.mat');
Database_All = data_plat.Database_All;
data2 = table2cell(Database_All(:, {'Plat', 'Nama', 'Jurusan', 'Status'}));
set(handles.uitable1, 'Data', data2);
If you want to filter your table to only include the rows that match a certain value, replace the : above by your filter, eg.:
data2 = table2cell(Database_All(strcmpi(Database_All.Plat, 'DD6713MT'), {'Plat', 'Nama', 'Jurusan', 'Status'}));
  5 Comments
Guillaume
Guillaume on 17 Aug 2017
I have no idea what the above sentence is saying, particularly "the car has pass away"
Yusran Said
Yusran Said on 17 Aug 2017
sorry, my englhis so bad, it mean when my system succes read noplate from a car, then data in table is missing when car is gone, i want data in table still exist even noplate alrdy not show in system,

Sign in to comment.

More Answers (1)

Ilham Hardy
Ilham Hardy on 17 Aug 2017
If you are asking how to get the value of row 1 column 2 of your data2 cell, try
no_plat = data2{1,2}; % get row 1 column 2 value of data2
  7 Comments
Yusran Said
Yusran Said on 17 Aug 2017
its still erorr Attempt to reference field of non-structure array.
Error in contoh>pushbutton1_Callback (line 86) idx = find(strcmpi('DD6713MT',data2.Plat));
can u tell me how can i use that code, i put that code in inside for n try too in out side for, ty for u attention buddy
Guillaume
Guillaume on 17 Aug 2017
find is rarely needed. In particular:
idx = find(somelogicalexpression);
result = somevector(idx);
is the same as
result = somevector(somelogicalexpression);
The latter being faster as well.

Sign in to comment.

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!