Académique Documents
Professionnel Documents
Culture Documents
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)
set(handles.edit8,'string',0);
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;
set(handles.edit7,'string',(altura/2)+1);
z=0:pi/100:2*pi;
x=(febb+2)/2+cos(z);
y=febb+sin(z);
axes(handles.axes1);
plot(x,y+1);
axis([-2 febb+5 -2 febb+5])
hold on;
pause(0.001)
if (masa~=0.81)
main(altura,masa,v);
end
function main(altura,masa,v)
A=["Masa" "Altura inicial" "Vo";masa altura v];
xlswrite('untitled.xlsx',A,'Hoja1','A1');
feb=altura;
dt=1/50;
db=masa*1500;
tf = sqrt(altura)*db;
g=-9.81;
times=dt:dt:tf;
time=0:1/(length(times)):1;
heights= zeros;
q=zeros(1,length(times));
p=zeros(1,length(times));
r=zeros(1,length(times));
for idx=1:length(times)
val=str2double(get(handles.edit8,'String'));
newh=altura +(v+g*dt/2)*dt;
posx=str2double(get(handles.edit7,'String'));
lv=v;
v=v+g*dt;
q(idx)=abs(newh);
p(idx)=abs(v);
r(idx)=posx;
set(handles.edit6,'string',times(idx));
if val==1
if newh < 0
k=0;
newh=0;
v=-v*sqrt(masa);
else
k=1;
end
set(handles.edit7,'string',((feb+1.5*time(idx))/2)+1);
heights(idx)=newh;
altura=newh;
if(k==0)
oval(0,heights(idx),feb+1.5*time(idx));
else
circle(0,heights(idx),feb+1.5*time(idx));
end
if(lv>=0 && v<=0 && altura<0.2)
for i=0:0.013:0.1
circle(0,0.1-i,feb+1.5*time(idx));
set(handles.edit8,'string',4);
end
break
end
end
if val==0
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
h (idx,times,p,q,r);
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,r)
clc;
xlswrite('untitled.xlsx',p(1:idx),'Hoja1','A3');
xlswrite('untitled.xlsx',q(1:idx),'Hoja1','A4');
xlswrite('untitled.xlsx',r(1:idx),'Hoja1','A5');
end
end
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
drawnow;
end
function iman(x,y,c)
cla;
curve = animatedline('LineWidth',1,'Color','r', 'Parent', handles.axes1);
z=-pi/2-1:pi/100:pi/2;
x=x+cos(z);
y=y+sin(z);
addpoints(curve,x+(c/2)+1,y+1);
drawnow;
end
posicionx=str2double(get(handles.edit7,'String'));
times=0:1/50:1;
val=str2double(get(handles.edit8,'String'));
if val==4
for idx=1:length(times)
iman(0,0,(((posicionx+2-1)+times(idx))*2));
circle(0,0,((posicionx-1)+times(idx))*2);
end
set(handles.edit7,'string',(posicionx)+1);
end
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 iman(x,y,c)
cla;
curve = animatedline('LineWidth',1,'Color','r', 'Parent', handles.axes1);
z=pi-1:pi/100:2*pi-1;
x=x+cos(z);
y=y+sin(z);
addpoints(curve,x+(c/2)+1,y+1);
drawnow;
end
posicionx=str2double(get(handles.edit7,'String'));
times=0:1/50:1;
val=str2double(get(handles.edit8,'String'));
if val==4
for idx=1:length(times)
iman(0,0,((posicionx-2-1)-times(idx))*2);
circle(0,0,((posicionx-1)-times(idx))*2);
end
set(handles.edit7,'string',(posicionx)-1);
end
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
end
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called