Puedo tener dos gráficas en un mismo axis
Publicado por Simona (15 intervenciones) el 03/08/2013 20:39:14
Hola, es que pretendo tener dos gráficas de caída libre y después de un objeto en el fluido , pero no sé como hacer para tener las dos gráficas en un mismo axis
así esta bien?
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)
global r ;
r=str2double(get(handles.radio,'String'));
global de ;
global vis;
yo=15;
vyo=0;
g=-9.8;
tcaidali=(yo*2/g)^(1/2);
t=0:1/50:5:(((6)^2/7)+20);
%tMax = 0;
%deltaT = 0.50;
%t = tcaidali;
%%Ecuaciones caida libre
x=0*t;
vy = vyo + g*t;
y=yo+vyo*t+(1/2)*g*t.^2;
%%%Material--->Cobre
densidadcobre=8500;
%Entra en el fluido a una altura de cinco metros
if yo==5
%%Ecuaciones Fluidos
m=(densidadcobre*(4/3)*pi*(r.^2));
b=(6*pi*r*vis);
E=(de*(4/3)*pi*(r.^3)*g);
vl=((2*r.^2*g*(densidadcobre-de))/(9*vis));
v=vl*(1-exp((-b*t/m)));
x=vl*(t-(m/b)*(1-exp((-b/m)*t)));
for i=1:length(t) % para animar las grafica
pause(1/50) % tiempo para que se detenga tiempo igual al de arriba
%subplot(2,2,1)% Matriz 2x2 posición1
plot(handles.axes1,t(i),vy(i))
xlabel(handles.axes1,'tiempo t(s)')
ylabel(handles.axes1,'Velocidad en Y - Vy (m/s)')
axis(handles.axes1,[min(t) max(t) min(vy) max(vy)])
hold (handles.axes1,'on')
yo=yo+1;
plot(handles.axes2,x(i),y(i), 'o r')
xlabel(handles.axes2,'Posición x(m)')
ylabel(handles.axes2,'Posición y(m)')
axis(handles.axes1,axis,[-2 2 min(y) max(y)])
hold (handles.axes2,'on')
plot(handles.axes1,t(i),v(i))
xlabel(handles.axes1,'tiempo t(s)')
ylabel(handles.axes1,'Velocidad en Vl - Vl (m/s)')
axis(handles.axes1,axis,[min(t) max(t) min(v) max(v)])
hold (handles.axes1,'on')
end
end
%tMax = 3;
%deltaT = 0.01;
%t = 0;
%Bola caida libre
%while tiempoTranscurrido < tMax
%caídalibre
%x =0*deltaT;
% y = yo+Vyo*deltaT+(1/2)*g*deltaT.^2;
% vy = vy + g*deltaT;
%plot(handles.axes2, t, vy);
% xlabel(handles.axes2,'tiempo en t(s).')
% ylabel(handles.axes2,'Velocidad en Vy(m/s)')
% axis([0 tMax -5 5])
% hold (handles.axes2,'on')
%end
%v=v2*(1-exp((-b/m)*t));
%x=vt*(t-(m/b)*(1-exp((-b/m)*t)));
%vl=(2*r^2*g*(de-df))*9*vis;
%b=(6*Pi*r*vis);
%E=(df*(4/3)*Pi*(r^3)*g);
%m=(de*(4/3)*Pi*(r^2));
%plotear v vs tiempo
así esta bien?
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)
global r ;
r=str2double(get(handles.radio,'String'));
global de ;
global vis;
yo=15;
vyo=0;
g=-9.8;
tcaidali=(yo*2/g)^(1/2);
t=0:1/50:5:(((6)^2/7)+20);
%tMax = 0;
%deltaT = 0.50;
%t = tcaidali;
%%Ecuaciones caida libre
x=0*t;
vy = vyo + g*t;
y=yo+vyo*t+(1/2)*g*t.^2;
%%%Material--->Cobre
densidadcobre=8500;
%Entra en el fluido a una altura de cinco metros
if yo==5
%%Ecuaciones Fluidos
m=(densidadcobre*(4/3)*pi*(r.^2));
b=(6*pi*r*vis);
E=(de*(4/3)*pi*(r.^3)*g);
vl=((2*r.^2*g*(densidadcobre-de))/(9*vis));
v=vl*(1-exp((-b*t/m)));
x=vl*(t-(m/b)*(1-exp((-b/m)*t)));
for i=1:length(t) % para animar las grafica
pause(1/50) % tiempo para que se detenga tiempo igual al de arriba
%subplot(2,2,1)% Matriz 2x2 posición1
plot(handles.axes1,t(i),vy(i))
xlabel(handles.axes1,'tiempo t(s)')
ylabel(handles.axes1,'Velocidad en Y - Vy (m/s)')
axis(handles.axes1,[min(t) max(t) min(vy) max(vy)])
hold (handles.axes1,'on')
yo=yo+1;
plot(handles.axes2,x(i),y(i), 'o r')
xlabel(handles.axes2,'Posición x(m)')
ylabel(handles.axes2,'Posición y(m)')
axis(handles.axes1,axis,[-2 2 min(y) max(y)])
hold (handles.axes2,'on')
plot(handles.axes1,t(i),v(i))
xlabel(handles.axes1,'tiempo t(s)')
ylabel(handles.axes1,'Velocidad en Vl - Vl (m/s)')
axis(handles.axes1,axis,[min(t) max(t) min(v) max(v)])
hold (handles.axes1,'on')
end
end
%tMax = 3;
%deltaT = 0.01;
%t = 0;
%Bola caida libre
%while tiempoTranscurrido < tMax
%caídalibre
%x =0*deltaT;
% y = yo+Vyo*deltaT+(1/2)*g*deltaT.^2;
% vy = vy + g*deltaT;
%plot(handles.axes2, t, vy);
% xlabel(handles.axes2,'tiempo en t(s).')
% ylabel(handles.axes2,'Velocidad en Vy(m/s)')
% axis([0 tMax -5 5])
% hold (handles.axes2,'on')
%end
%v=v2*(1-exp((-b/m)*t));
%x=vt*(t-(m/b)*(1-exp((-b/m)*t)));
%vl=(2*r^2*g*(de-df))*9*vis;
%b=(6*Pi*r*vis);
%E=(df*(4/3)*Pi*(r^3)*g);
%m=(de*(4/3)*Pi*(r^2));
%plotear v vs tiempo
Valora esta pregunta
0