필터 지우기
필터 지우기

gui error

조회 수: 1 (최근 30일)
pawan kumar
pawan kumar 2011년 9월 22일
this programme is for flatfire trajectory of projectile,i solved it using odesolver(ode45)with event location;i made its gui by dirrectly drag and drop buttons from options and linked this programme in to the gui programme with pushbutton. i define function which odesolver will call just above the pushbutton and put the solver programmme inside the push button. i am taking some input from user which is being used in the programme .so that after pressing button it can execute the programme.but i found an error.if i simply(not from gui) run this programme from .m file it doesn't give error.this is the error which command window is showing;
??? Reference to a cleared variable handles.
Error in ==> guiflatfiredragwind>pushbutton1_Callback at 257 v0 = str2num(get(handles.edit1,'String'));
this is the programme which i have defined, function [value,isterminal,dircn] = fnflatfiredragwind(t,c,flag,w1,w2,w3,k) g = 9.8; % c(1) = x; c(2) = dx/dt = vx ; c(3) = y ; c(4) = dy/dt = vy ; c(5) = w % c(6) = dc/dt = vc
if nargin<7 isempty(flag)
value = [c(2); -k*(c(2)-w1)^2; c(4); (-k*(c(2)-w1)*(c(4)-w2))-g; c(6); -k*(c(2)-w1)*(c(6)-w3)];
else
switch flag
case 'events'
value = c(3);
isterminal = 1;
dircn = 0;
otherwise
error('function not programmed for this event');
end
end
% --- 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)
disp('programme for simple trajectory using ode solver') % here tspan is the approximation time for the event occur i-e y = 0; tspan = [0 10]; % for the graph should be smooth time approximation must be near flight % time
v0 = str2num(get(handles.edit1,'String'));
theta = str2num(get(handles.edit2,'String'));
w1 = str2num(get(handles.edit3,'String'));
w2 = str2num(get(handles.edit4,'String'));
w3 = str2num(get(handles.edit5,'String'));
k = str2num(get(handles.edit6,'String'));
c0 = [0; v0*cos(theta); 1; v0*sin(theta); 0; 0];
options = odeset('events','on');
[t,c,te,ze,ie] = ode45('fnflatfiredragwind',tspan,c0,options,w1,w2,w3,k);
how will i solve this problem; reply soon, thanks pawan kumar
  댓글 수: 1
Jan
Jan 2011년 9월 22일
Please use code formatting to improve the readability of your code - follow the "Markup help" link on this page to learn how to do this.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2011년 9월 22일
The error message seems to be descriptive:
??? Reference to a cleared variable handles.
Error in ==> guiflatfiredragwind>pushbutton1_Callback at 257
v0 = str2num(get(handles.edit1,'String'));
Obviously the variable handles is out of date. The description "if i simply (not from gui) run this programme from .m file" is not precise enough to find the cause of this problem. I suggest to use the debugger:
dbstop if error
Then Matlab stops, if the problem occurs and you can inspect the current variables.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by