Changing the parameters of a graph by GUI

3 visualizaciones (últimos 30 días)
Harshal
Harshal el 30 de Jul. de 2012
Hello everyone, I want to develop a GUI with which I can change the title, X-Axis and Y-Axis labelling of the figure named 'trial_for_graphic'. I want to change the title, xlabel and the ylabel of the same figure. However, when I run the code (given below),it generates a different window figure for every option. So, I cannot change the title, xlabel and ylabel in the same figure window. Can anyone please tell me as to how I can change the three parameters in the same figure window ?
val = get(handles.popupmenu_select_parameter,'Value');
string = get(handles.popupmenu_select_parameter,'string');
string2 = get(handles.edit1,'string');
open('trial_for_graphic.fig')
switch val
case 2
title(string2)
case 3
xlabel(string2)
case 4
ylabel(string2)
end

Respuestas (3)

venkat vasu
venkat vasu el 30 de Jul. de 2012
before entering the switch case you open the figure window like this;
figure; switch val
case 2
hold on
title(string2)
case 3
hold on
xlabel(string2)
case 4
hold on
ylabel(string2)
end
  3 comentarios
venkat vasu
venkat vasu el 30 de Jul. de 2012
same code working fine in my system can you tell me what exactly have to do
Harshal
Harshal el 30 de Jul. de 2012
Well, what I want to do is that I want to change the parameters of the graph, one by one. So, when I change the title by choosing 'title' from the GUI popupmenu, the title of the trail_for_gui.fig is changed, in the figure1 window. When I now select the xlabel option from GUI popupmenu, it should change the xlabel of trial_for_figure.fig in the same windoe (i.e figure1). However, when I run my code, it opens another window (figure2) and then changes the xlabel. So, I have two windows of same graph, one with its title changed and the other with its xlabel changed.

Iniciar sesión para comentar.


venkat vasu
venkat vasu el 30 de Jul. de 2012
switch val
case 2
hold on
title(string2)
hold off
case 3
hold on
xlabel(string2)
hold off
case 4
hold on
ylabel(string2)
hold off
end
check it this code also

venkat vasu
venkat vasu el 30 de Jul. de 2012
i have created some example gui check this.
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) hold on h=title('hhhh');
% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) hold on xlabel('hhhhhhhghgf');
% --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) hold on ylabel('hhhhhhhghgfgjjg');
  3 comentarios
Harshal
Harshal el 30 de Jul. de 2012
I am using MATLAB 7.2. Does this have anything to do with the code that you gave in the first answer. (which works in your MATLAB, but not in my)
venkat vasu
venkat vasu el 31 de Jul. de 2012
i'm working in 2011b its working fine.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by