How to plot the example of the spherical pendulum with the lagrange metrod using matlab
MATLAB CODE:
clear all;
R=1;% Length of the connecting rope
g=9.81;
y10=[0.4*pi 0 0 1.5]; % Initial Conditions [ theta theta' phi
phi']
tspann=[0 10];% Duration of movement
%f=@(t,y)[y(2); ( m2*sin(y(3))*( 9.81*cos(y(3)) + l*(y(4))^2 ) )/(
m2+m1 -m2*(cos(y(3)))^2 ) ; y(4) ;
((-cos(y(3)))/l)*(m2*sin(y(3)))*( 9.81*cos(y(3)) + l*(y(4))^2 ) )/(
m2+m1 -m2*(cos(y(3)))^2 )-(9.81*sin(y(3)))/l ];
f=@(t,y)[y(2);((
y(4))^2).*sin(y(1)).*cos(y(1))-(g/R).*sin(y(1));y(4);-2.*(cos(y(1)).*y(2).*y(4))./(sin(y(1)))];
[t,y]=ode45(f,tspann,y10);
X=R.*cos(y(:,3)).*sin(y(:,1));
Y=R.*sin(y(:,3)).*sin(y(:,1));
Z=R.*cos(y(:,1));
%%
hold on;
r=1;
funx = @(u,v) r.*cos(u).*sin(v);
funy = @(u,v) r.*sin(u).*sin(v);
funz = @(u,v) r.*cos(v);
fsurf(funx,funy,funz,[0 2*pi 0.6*pi
pi],'FaceAlpha',0.4,'MeshDensity',10) ; % ,'FaceColor','b'
camlight;
title('Spherical pendulum');
axis([-1 1 -1 1 -1 1]);
grid on;
axis equal;
xlabel('x');
ylabel('y');
zlabel('z');
scatter3(0,0,-1,'o y','LineWidth',1.2);
plot3([0 0],[0 0],[0 -1],' - k','LineWidth',1.2);
scatter3(0,0,0,'o r','LineWidth',1.2);
plot3(X,Y,-Z,'y -','LineWidth',1.1)
How to plot the example of the spherical pendulum with the lagrange metrod using matlab
USE MATLAB ALSO PLOT THE PENDULUM animation
Case 1: Pendulum
Create a plot that shows a pendulum moving.
First,use the ode45 function to solve the pendulum equation
between 0 and 10 seconds. The pendulum equation is:
Create a plot that shows a pendulum moving First, use the ode45 function to solve the pendulum equation between 0 and 10 seconds. The pendulum equation is: + sin(e) 0 where g is gravity and L is the length of the pendulum bar. Use...
using Matlab
Assignment 9.3: ODE Ill or pendulum Ill Solve the equation for the small amplitude pendulum without driving forces but with damping: dt2 Use your RK4 routine. Plot the result.
Assignment 9.3: ODE Ill or pendulum Ill Solve the equation for the small amplitude pendulum without driving forces but with damping: dt2 Use your RK4 routine. Plot the result.
Problem 5 (programming): Create a MATLAB function named lagrange interp.m to perform interpolation using Lagrange polynomials. Download the template for function lagrange interp.m. The tem Plate is in homework 4 folder utl TritonED·TIue function lakes in the data al nodex.xi and yi, as well as the target x value. The function returns the interpolated value y. Here, xi and yi are vectors while x and y are scalars. You are not required to follow the template; you can create the...
How to plot the magnetic flux density for the concentric hollow cylinders using matlab
solve this using matlab
and post the code on how to solve for it and plot it as
well
i know the picture is there but i want to learn how to plot it
on matlab please
- 1/2 The orbit of Pluto is elliptical in shape, with a = 5.9065 x 109 km and b = 5.7208 x 109 km The perimeter of an ellipse can be calculated by P = 401 V1 –k? sin’e ao where k =...
How do I solve using Matlab?
Plot a star that prompts the user to enter how many points the star has. Only worry about odd numbered points. Indicate to the user only odd numbers can be entered. Change the star line color to red.
Problem 4 For Poisson's ratio of 0.3, write a MATLAB code to plot the principal stress and maximus shear for two spherical bodies in contact
Problem 4 For Poisson's ratio of 0.3, write a MATLAB code to plot the principal stress and maximus shear for two spherical bodies in contact
Using Matlab. I need the matlab code for: a. Plot a 1 Hz sine wave b. Plot the unit rectangle function. c. Plot the unit triangle function Show each over a plotting interval -5 sec to 5 sec.
Plot f(x) = x^3 - y using MATLAB. Include zero crossings in the plot.
Matlab: Study the effects of damping by starting a pendulum (use l = 9.81 m and q = 0.1) with an initial displacement (θ = 0.5 rad, for example). Estimate the time constant for the decay of the pendulum oscillation obtained with these values.