現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
how to retrieve array data with the help of index in matlab uiTable
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Walter Roberson
2017 年 6 月 5 日
Could you give a small example? I can see several possible meanings for your question?
採用された回答
Walter Roberson
2017 年 6 月 5 日
[tf, idx] = ismember(ThisPlateString, CellArrayOfPlateStrings);
if ~tf
msgbox('No match')
else
Information_About_This_Plate = Information_About_All_Plates(idx, :);
end
35 件のコメント
Rya
2017 年 6 月 5 日
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
Walter Roberson
2017 年 6 月 5 日
[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 ?
Walter Roberson
2017 年 6 月 6 日
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.)
Walter Roberson
2017 年 6 月 7 日
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'
Rya
2017 年 6 月 7 日
yes i got it but this code works in command prompt but it doesn't work in m file, why??
Walter Roberson
2017 年 6 月 7 日
編集済み: Walter Roberson
2017 年 6 月 7 日
Post your current code. And the complete error message
Walter Roberson
2017 年 6 月 7 日
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');
Rya
2017 年 6 月 8 日
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');
Jan
2017 年 6 月 8 日
"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.
Rya
2017 年 6 月 8 日
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
Walter Roberson
2017 年 6 月 8 日
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.
Walter Roberson
2017 年 6 月 9 日
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.
Rya
2017 年 6 月 11 日
did u find any solution ?? I have tried so many solutions but google search suck so bad now.
Rya
2017 年 6 月 11 日
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');
Walter Roberson
2017 年 6 月 11 日
Not
axis(ax, image, 'off')
The 'image' part needs to be quoted, axis(ax, 'image', 'off')
Rya
2017 年 6 月 11 日
編集済み: Rya
2017 年 6 月 11 日
[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
Walter Roberson
2017 年 7 月 10 日
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)