how to retrieve array data with the help of index in matlab uiTable

I want to access array data in Matlab GUI, i want to search the record from array on the basis of an index
load ANPR
if ismember(noPlate,ANPR(:,2))
msgbox( 'The number is Registered in database');
else
msgbox( 'The number is not Registered in database');
Info of all plate lies in VehicleDes.mat, the number is stored in noPlate after matching noPlate in array ANPR.mat i also want to show the detail information of that noPLate that lies in array VehicleDes,it might shown after clicking on ok button of msgbox or another option is to show data in uitable plz suggest how to do that

4 Comments

Could you give a small example? I can see several possible meanings for your question?
As we retrieve data from database tables using some condition, like show the record of vehicle whose license number matches with the number input in textbox
@Rya: do you see how your comment is formatted like code? Do NOT put a space at the beginning of your comment and then it will be formatted as normal text.

Sign in to comment.

 Accepted Answer

[tf, idx] = ismember(ThisPlateString, CellArrayOfPlateStrings);
if ~tf
msgbox('No match')
else
Information_About_This_Plate = Information_About_All_Plates(idx, :);
end

35 Comments

load ANPR
if ismember(noPlate,ANPR(:,2))
msgbox( 'The number is Registered in database');
else
msgbox( 'The number is not Registered in database');
Info of all plate lies in VehicleDes.mat, the number is stored in noPlate after matching noPlate in array ANPR.mat i also want to show the detail information of that noPLate that lies in array VehicleDes,it might shown after clicking on ok button of msgbox or another option is to show data in uitable plz suggest how to do that
[tf, idx] = ismember(noPlate, ANPR(:,2));
if ~tf
msgbox( 'The number is not Registered in database');
Information_About_This_Plate = {};
else
index_in_database = ANPR{idx, 1};
Information_About_This_Plate = VehicleDes(index_in_database, :);
msgbox( ['The number is Registered to', Information_About_This_Plate{2}] );
end
However, in the data you posted for ANPR,
[2] 'KPT295'
implies that plate KPT295 should be the second plate in VehicleDes, but it is the first (and only) plate instead. Should we be ignoring the information in the first column of ANPR ?
No that was a dummy data only Here is a complete file of vehicle description.
no no sorry I don't want to show a dilog-box here, i want to show-up a new form/figure or maybe uitable which is possible to displays all the information related to noPlate
like this, How could it be possible? please help
You can create a figure() and put uicontrol('style', 'text') fields up with different background colors. The easiest way to display an image is to put an axes in and display the image on the axes with image() (I would not recommend imshow() for this purpose.)
please convert the above code for all the number plates instead of a single
and please tell how do i show this msgbox output in uicontrols????
What do you mean for all of the plates? Your noPlate variable is a single character vector indicating one plate to look up.
Instead of msgbox you can set(( ) the String field of a uicontrol 'style', 'text'
yes i got it but this code works in command prompt but it doesn't work in m file, why??
Post your current code. And the complete error message
It comes in this format can u please provide me a small example of using set property so that i could get exactly form like format
And also tell how to show image from cell array along with these fields
bgcol = [.6 .58 .63];
datacol = [.8 .8 .8];
fig = figure('color', bgcol, 'Units', 'pixels', 'Position', SOMETHING0);
L1 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING1, 'background', bgcol, 'string', 'Make:');
L2 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING2, 'background', bgcol, 'string', 'Model:');
L3 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING3, 'background', bgcol, 'string', 'Year:');
L4 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING4, 'background', bgcol, 'string', 'Doors:');
D1 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING5, 'background', datacol, 'string', car_make);
D2 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING6, 'background', datacol, 'string', car_model);
D3 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING7, 'background', datacol, 'string', car_year);
D4 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'Position', SOMETHING8, 'background', datacol, 'string', car_doors);
ax = axes(fig, 'Units', 'pixels', 'Position', SOMETHING9, 'color', bgcol)
imh = image(ax, car_image);
axes(ax, 'image', 'off');
The SOMETHING are positions to place and size the text boxes
But I'm unable to show image plz tell me where I m wrong!
ax = axes(fig, 'Units', 'pixels', 'Position', [400 150 150 40], 'color', bgcol)
imh = image(ax, Information_About_This_Plate{7});
axes(ax, 'image', 'off');
"Unable" does not explain what happens. Do you get an error message? Note that axes does not accept the shown arguments, but axis (with i) would.
i asked for error in code as I'm sure i did somewhere wrong in code. so here is a Error message
Error using axes
Too many input arguments.
Error in Main>Untitled_1_Callback (line 349)
ax = axes(fig, 'Units', 'pixels', 'Position', [400 150 150 40])
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Main (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Main('Untitled_1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uimenu Callback
Change
ax = axes(fig, 'Units', 'pixels', 'Position', SOMETHING9, 'color', bgcol)
to
ax = axes('Parent', fig, 'Units', 'pixels', 'Position', SOMETHING9, 'color', bgcol)
if you are using R2015b or older.
i think image is 8bit integer so i have to first convert it into double? if i m not wrong?
Error using image
Incorrect number of arguments specified
Error in Main>Untitled_1_Callback (line 350)
image(ax, Information_About_This_Plate{7});
If you are using a really old version of MATLAB, then you might need
image(Information_About_This_Plate{7}, 'Parent', ax);
However, is it possible that Information_About_This_Plate{7} is empty? That would lead to that error being generated.
No its not empty each cell is containing data, after implementing above line of code, this color mixture shown up instead of image , with error
Error using axes
Too many input arguments.
Error in Main>Untitled_1_Callback (line 354)
axes(ax, image, 'off');
did u find any solution ?? I have tried so many solutions but google search suck so bad now.
Change
axes(ax, 'image', 'off');
to
axis(ax, 'image', 'off');
thsi is used to hide the axis??
still error
Error using axis>LocSetLimits (line 227)
Vector must have 4, 6, or 8 elements.
Error in axis (line 93)
LocSetLimits(ax(j),cur_arg);
Error in Main>Untitled_1_Callback (line 360)
axis(ax, image, 'off');
Not
axis(ax, image, 'off')
The 'image' part needs to be quoted, axis(ax, 'image', 'off')
image in cell is not showing up, even it doesn't show error related to this
Please post your current version of the code.
[tf, idx] = ismember(noPlate, NPR(:,2));
if ~tf
msgbox( 'The number is not Registered in database');
Information_About_This_Plate = {};
else
index_in_database = NPR{idx, 1};
Information_About_This_Plate = DB(index_in_database, :);
bgcol = [.83 .82 .78];
datacol = [1 1 1];
label=[.93 .93 .93];
fig = figure('color', bgcol, 'Units', 'pixels','Position', [10, 50, 669, 420],'Name','Vehicle Description Panel');
L0 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 10,'Position', [0 370 50 30], 'background', bgcol, 'string', 'VPN:');
L1 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 15,'Position', [10 330 150 40], 'background', bgcol, 'string', 'Owner:');
L2 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 15, 'Position',[10 270 150 40], 'background', bgcol, 'string', 'Vehicle Type:');
L3 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 15, 'FontSize', 15,'Position',[10 220 150 40], 'background', bgcol, 'string', 'Color:');
L4 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'FontSize', 15,'Position',[10 170 150 40], 'background', bgcol, 'string', 'Make:');
L6 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 15,'Position', [10 120 150 40], 'background', bgcol, 'string', 'Model:');
L7 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 15, 'Position',[10 70 150 40], 'background', bgcol, 'string', 'Year:');
D0 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'FontSize', 10,'Position',[50 370 50 30], 'background',bgcol, 'string', Information_About_This_Plate{1});
D1 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'FontSize', 10,'Position',[170 330 150 40], 'background',datacol, 'string',(Information_About_This_Plate{2}));
D2 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'FontSize', 10,'Position',[170 270 150 40], 'background', datacol, 'string', Information_About_This_Plate{3});
D3 = uicontrol(fig, 'style', 'text', 'units', 'pixels', 'FontSize', 10,'Position', [170 220 150 40], 'background', datacol, 'string', Information_About_This_Plate{4});
D4 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 10, 'Position', [170 170 150 40], 'background', datacol, 'string', Information_About_This_Plate{5});
D5 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 10, 'Position',[170 120 150 40], 'background',datacol, 'string', Information_About_This_Plate{6});
D6 = uicontrol(fig, 'style', 'text', 'units', 'pixels','FontSize', 10, 'Position',[170 70 150 40], 'background', datacol, 'string', Information_About_This_Plate{7});
ax = axis('Parent', fig, 'Units', 'pixels', 'Position', [100 210 380 150])
% ax = axis(fig, 'Units', 'pixels', 'Position', [400 30 20 50])
ax=image(Information_About_This_Plate{8}, 'Parent', ax);
axis(ax, 'image', 'off');
end
You have
ax=image(Information_About_This_Plate{8}, 'Parent', ax);
axis(ax, 'image', 'off');
The first of those two lines overwrites ax with the handle to an image. You need to use a different output variable name.

Sign in to comment.

More Answers (0)

Categories

Find more on Display Image in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!