Академический Документы
Профессиональный Документы
Культура Документы
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
end
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
end
end
end
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
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)
cla;
cla (handles.axes2, 'reset' );
cla (handles.axes3, 'reset' );
altura=str2double(get(handles.edit2,'String'));
febb=altura;
masa =(80-str2double(get(handles.edit1,'String')))*0.01+0.01;
cla;
v=str2double(get(handles.edit3,'String'));
cla;
z=0:pi/100:2*pi;
x=(febb+2)/2+cos(z);
y=febb+sin(z);
axes(handles.axes1);
plot(x,y+1);
axis([0 febb+2 0 febb+2])
hold on;
pause(0.001)
if (masa~=0.81)
main(altura,masa,v);
end
function main(altura,masa,v)
feb=altura;
dt=1/50;
db=masa*1500;
tf = sqrt(altura)*db;
g=-9.81;
times=dt:dt:tf;
heights= zeros;
q=zeros(1,length(times));
p=zeros(1,length(times));
for idx=1:length(times)
newh=altura +(v+g*dt/2)*dt;
lv=v;
v=v+g*dt;
q(idx)=abs(newh);
p(idx)=abs(v);
if newh < 0
k=0;
newh=0;
v=-v*sqrt(masa);
else
k=1;
end
heights(idx)=newh;
altura=newh;
if(k==0)
oval(0,heights(idx),feb);
else
circle(0,heights(idx),feb);
end
break
end
h (idx,times,p,q);
end
end
function oval (x,y,c)
cla;
curve = animatedline('LineWidth',1,'Color','k', 'Parent', handles.axes1);
z=0:pi/100:2*pi;
x=x+1.2*cos(z);
y=y+sin(z);
addpoints(curve,x+(c/2)+1,y+1);
drawnow;
end
function circle(x,y,c)
cla;
curve = animatedline('LineWidth',1,'Color','k', 'Parent', handles.axes1);
z=0:pi/100:2*pi;
x=x+cos(z);
y=y+sin(z);
addpoints(curve,x+(c/2)+1,y+1);
drawnow;
end
function h (idx,times,p,q)
clc;
end
end
drawnow;
end
function iman(x,y,c)
cla;
curve = animatedline('LineWidth',1,'Color','r', 'Parent', handles.axes1);
z=pi:pi/100:2*pi;
x=x+cos(z);
y=y+sin(z);
addpoints(curve,x+(c/2)+1,y+1);
drawnow;
end
d=get(hObject,'Value');
dt=1/90;
u=abs(d-w);
times=dt:dt:u;
if d<w
for idx=1:length(times)
circle(0,0,febb-times(idx)+w);
iman(0,-0.5,febb-times(idx)+w);
end
else
for idx=1:length(times)
circle(0,0,febb+times(idx)+w);
iman(0,-0.5,febb+times(idx)+w);
end
end
w=d;
end
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, ~, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called