Prev: precision
Next: Least square fitting
From: jens on 22 Apr 2010 14:15 Hi All I have a GUI that contain a checkbox with a pushbutton. When I press the pushbutton it runs the function under. The function contain a switch statement where the case that is run depend on the choice/value choosen from the checkbox. The code work fine, but I want to optimize my code.For every case in the switch statement Ii plot a function and different cases/plot data can be added to the same plot. The problem is that I want to avoid that I for every case has to define all these axes handles like axes, labels, grid on and titles? I want to defind it from the start if possible as I do with the size of the figure window? Is there some way that I can define the axes,labels, grid and titles from the start and avoid defining it for every case? Best Regards Jens function[]=test(varargin) choice=get(checkboxhandle,'value') h2=figure(2) set(h2,'Position', [0 0 1 1]) switch choice case 1 x1=........... y1=.......... lineHdl1(1)=semilogx(x1,y1,'color',[rand rand rand]')% line handle axis([0 10 0 10]) xlabel('time') ylabel('Money') title('Test')' grid on hold on case 2 x2=........... y2=.......... lineHdl1(2)=semilogx(x2,y2,'color',[rand rand rand]') axis([0 10 0 10]) xlabel('time') ylabel('Money') title('Test')' grid hold on case 3 ........... case 4 ............ end
From: Beskie on 22 Apr 2010 14:38 you can put your plot parameters into a function function plot_data x=1:1:10; y=1:1:10; plot(x,y) plot_settings end function plot_settings axis([0 10 0 10]) xlabel('time') ylabel('Money') title('Test') grid on hold on end
From: Beskie on 22 Apr 2010 14:44 Or just put your plot parameters after the switch end.
From: jens on 22 Apr 2010 15:34 Beskie <beskie783(a)yahoo.com> wrote in message <e3659e9f-6594-41b1-9b58-78cafa9e124f(a)s21g2000pri.googlegroups.com>... > Or just put your plot parameters after the switch end. Thanks Beskie I will put the parameters after the switch statement:) Best Regards Jens
|
Pages: 1 Prev: precision Next: Least square fitting |