0% found this document useful (0 votes)
4 views5 pages

Matlab Apoyo

wy3y5y

Uploaded by

Charles Jl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Matlab Apoyo

wy3y5y

Uploaded by

Charles Jl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

(<) (>) ^ [] ~ ∑

Tamaño Matriz: size( A )

clc
clear all

g = 9.8;
Vo = input('Data_Vo ');
teta = input('Data_teta ');
H = input('Data_H ');
teta = teta*3.1416/180;
t = (Vo*sin(teta)) + ((Vo*sin(teta))^2 + 2*H*g)^0.5/g;
xmax = Vo*cos(teta)*t;
ymax = H + ((Vo*sin(teta))^2)/(2*g);
t1 = [0:0.05:t];
xmax = Vo*cos(teta)*t1;
y = H + (Vo*sin(teta)).*t1-(0.5*g).*(t1.^2);
X = Vo*cos(teta).*t1;
y2 = H + (tan(teta).*X) - (0.5*g/(Vo*cos(teta))^2).*(X.^2);

figure(1),plot(t1,y,'*'), title('Graf Y vs
t'),xlabel('t[segund]'),ylabel('Y[mts]')

figure(2),plot(X,y2,'r*'), title('Graf Y vs
X'),xlabel('X[metrs]'),ylabel('Y[metrs]')

FUNCTION GRAPHIC

function freq_Callback(hObject, eventdata, handles)


t = 0:0.01:2*pi;
freq = get(handles.freq,'Value');
Amp = str2double(get(handles.a,'string'));
theta = str2double(get(handles.fase,'string'));
y = Amp*sin(2*pi*freq*t + theta);
plot(handles.axes1,t,y)

FUNCTION CAIDA LIBRE

% --- Executes on button press in caida.


function caida_Callback(hObject, eventdata, handles)
cla(handles.graf,'reset');
Vo = str2num(get(handles.vel,'string'));
theta = str2num(get(handles.angulo,'string'));
H = str2num(get(handles.altura,'string'));
g = 9.8;
t = ((Vo*sin(theta)) + ((Vo*sin(theta))^2 + 2*H*g)^0.5)/g;
theta = theta*pi/180;
xmax = Vo*cos(theta)*t;
ymax = H + ((Vo*sin(theta))^2)/(2*g);
for i=1:0.5:xmax
y3 = H + (tan(theta)*i) - (0.5*g/Vo*cos(theta)^2)*(i^2);
hold on;
pause(0.1);
plot(handles.graf,i,y3,'r--*','LineWidth',2)
legend('Objeto en mov')
grid on, xlabel('Dist recorrido'),ylabel('Altura')
end

FUNCTION SENO DINAMICO

~
clc
clear all
x = 0:pi/120:4*pi;
y = sin(x);
for i=1:length(x)
plot(x(i),y(i),'*','LineWidth',2);
hold on
plot(x(1:i),y(1:i),'LineWidth',2);
axis([0 4*pi,-2 2]);
pause(0.01);
if i~=length(x)
clf
end
end

RESORTE

Xo = 90;
Vo = 100;
k = 1.5;
m = 7.5;
g = 9.8;
R = 0.35;
for t=0:0.0005:5
a=(-k*Xo/m)-g-(R*Vo/m)
Vo = Vo+a*t;
Xo = Xo+Vo*t;
plot(t,Xo,'kp')
hold on
grid on
pause(0.0005)
end

Método de Runge Kutta

syms x y
fxy = -2*x^3+12*x^2-20*x+8.5
x0 = 0;
y0 = 1;
h = 0.5;
n = 10;
M = zeros(n,2);
for i=1:n
y_ast = double(y0+h*subs(fxy,[x y],[x0 y0]));
y_sig = double(y0+h*(subs(fxy,[x y],[x0 y0])+subs(fxy,[x y],[x0+h
y_ast]))/2);
x0 = x0+h;
y0 = y_sig;
M(i,1)=x0;
M(i,2)=y0;
end
disp('los valores de x e y son:')
M
plot(M(:,1)',M(:,2)','r*')

Método de Runge Kutta


syms x y
fxy = -2*x^3+12*x^2-20*x+8.5
x0 = 0;
y0 = 1;
h = 0.5;
n = 10;
M = zeros(n,2);
for i=1:n
k1 = subs(fxy,[x y],[x0 y0]);
k2 = subs(fxy,[x y],[x0+h/2 y0+k1*h/2]);
k3 = subs(fxy,[x y],[x0+h/2 y0+k2*h/2]);
k4 = subs(fxy,[x y],[x0+h y0+k3*h]);
y_sig = y0+h*(k1+2*k2+2*k3+k4)/6;
x0 = x0+h;
y0 = y_sig;
M(i,1) = x0;
M(i,2) = y_sig;
end
disp('Valores de x e y')
M
plot(M(:,1),M(:,2),'r*')
SUSTITUCION

function X=Susty(C)
n=length(C)-1;
m=n+1;
X(n)=C(n,m)/C(n,n)
for i=n-1:-1:1
suma=C(i,m);
for j=i+1:n
suma=suma-C(i,j)*X(j);
end
X(i)=suma/C(i,i);
end
for i=1:n
fprintf('x(%2.0f) %5.5f\n',i, X(i))
end

You might also like