I have created a set of gui's and i have inserted next button to navigate to the next gui. in the next gui i have a load button and an axes to display the image but if i select an image it gives me an error. the error is displayed below.

Attempt to reference field of non-structure array.
Error in LBPFeature>pushbutton1_Callback (line 84) axes(handles.axes1)
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in LBPFeature (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)LBPFeature('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
What can i do to display the image? if i open each gui individually i can load the image but if i navigate im not able to load the image. Please help me

1 件のコメント

Jeevan
Jeevan 2014 年 5 月 6 日
[filename pathname]=uigetfile({'*.bmp';'*.jpg'},'File Selector'); image=strcat( pathname, filename) axes(handles.axes1) imshow(image)
This is the code used to load an image.. and the error is in "axes(handles.axes1)" how can i fix this error?

サインインしてコメントする。

 採用された回答

nl2605
nl2605 2014 年 5 月 6 日
It doesn't know what handles.axes1 is. First use h = findobj('Tag',axes1) and then axes(h). I think it should work.

25 件のコメント

Jeevan
Jeevan 2014 年 5 月 6 日
Undefined function or variable 'axes1'. i got this error after trying the above mentioned method
Jeevan
Jeevan 2014 年 5 月 6 日
what do i do now? can u help me?
nl2605
nl2605 2014 年 5 月 6 日
編集済み: nl2605 2014 年 5 月 6 日
I am sorry add axes1 in quotes 'axes1' Like
h = findobj('Tag','axes1')
By the way I hope axes1 is the tag for your axes. Just check it once in the Property Inspector.
Jeevan
Jeevan 2014 年 5 月 6 日
Yes axes1 is the tag for it. Thanks alot it worked:) :) and one more question..i have used 4 axes in a single gui and two gui's are there of such type. if i apply the same logic does it work?
Jeevan
Jeevan 2014 年 5 月 6 日
Now i have the same problem but it is for the edit text field
my code is set(handles.edit1,'String',num2str(h_dist1)); set(handles.edit2,'String',num2str(h_dist2)); set(handles.edit3,'String',num2str(h_dist3));
error is Attempt to reference field of non-structure array.
Error in LBPFeature>TestingLBP_Callback (line 268) set(handles.edit1,'String',num2str(h_dist1));
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in LBPFeature (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)LBPFeature('TestingLBP_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
nl2605
nl2605 2014 年 5 月 6 日
The same logic applies for any graphic object(editbox,listbox,buttons). You can first find the editbox using findobj and then set the string value.
Jeevan
Jeevan 2014 年 5 月 6 日
ok how do i write the code is this correct?
a=findobj('Tag','edit1'); edit1(a);
Jeevan
Jeevan 2014 年 5 月 6 日
when i press the push button the values computed by h_dist1,2,3 should be displayed on the edit box 1,2 and 3 respectively..so is the above code correct?
a = findobj('Tag','edit1');
set(a,'String',num2str(h_dist1));
Jeevan
Jeevan 2014 年 5 月 6 日
Thanks alot it works like a charm :) :) :) if u dont mind one more question in my gui when i press the close button or back button the current gui should close completely and open the specified gui
i have used the following code.. close(LBPFeature) open FeatureMethods.fig
but the LBPFeature gui doesnt close it flashes and opens again what is the solution for this?
nl2605
nl2605 2014 年 5 月 6 日
That's strange. Try close(gcf). Since LBPFeature is your current figure.
Jeevan
Jeevan 2014 年 5 月 6 日
編集済み: Jeevan 2014 年 5 月 6 日
Thanks alot:) :) U made my day :) :) :) Thank you answering quickly and everything worked :) :)
nl2605
nl2605 2014 年 5 月 6 日
Glad! :)
Jeevan
Jeevan 2014 年 5 月 6 日
Can i know how to change the color of the string that i display in edit text box? i need to print YES in Green and NO in red how can i do this?
nl2605
nl2605 2014 年 5 月 6 日
Use Foreground Color in the same set command. Also, check Color Properties because there are different rgb values you have to give to this Property. Just check the property inspector and you will be amazed to see how many things you can do.
Jeevan
Jeevan 2014 年 5 月 6 日
sorry for the wrong question. my question is i have set a value for h_dist variable..if the generated value exceeds the set value i wanna print NO(in red color) and if it is less than that it should print YES(in green color). both yes and no can appear in the edit box. How to do this? Any idea?
nl2605
nl2605 2014 年 5 月 6 日
Yes, it can be done using set command. Following the same set of commands you have used till now. Just there will be an if else statement too.
Jeevan
Jeevan 2014 年 5 月 6 日
編集済み: Jeevan 2014 年 5 月 6 日
set(g,'Color','r');
is this right?
g is the color and r is the variable in which i have stored the string
nl2605
nl2605 2014 年 5 月 6 日
There is no Property called 'Color' for edit text. set(g,'Foreground Color','r'); I am not sure about the 'r'. Check the Color Properties.
Jeevan
Jeevan 2014 年 5 月 6 日
Thank you will check it out :) :) :)
Jeevan
Jeevan 2014 年 5 月 6 日
it working for a rectangle.
if i type this set(r,'edgecolor','g'); its showing me a rectangle with green edges..
but not able to set the Text color
nl2605
nl2605 2014 年 5 月 7 日
For Text Color its Foreground Color that you have to set.
Jeevan
Jeevan 2014 年 5 月 7 日
Yes i have tried "set(a,'ForegroundColor','r');" it buy it shows me the following error
Error using set Value must be a handle
Error in LBPFeature>TestingLBP_Callback (line 298) set(a,'ForegroundColor','r');
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in LBPFeature (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)LBPFeature('TestingLBP_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
>>
Jeevan
Jeevan 2014 年 5 月 7 日
Is there any other method to set the text color?
nl2605
nl2605 2014 年 5 月 8 日
I searched for it. It won't be possible to do it in the Callback function of your edit text. YOu can do it in another Keypressfcn. But I still am not sure if 'Color' would work with set. Sorry, couldn't be of more help. Post it in another thread. Maybe someone will know the answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2014 年 5 月 6 日

コメント済み:

2014 年 5 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by