% call: >>
double_pendulum([pi;0;pi;5;9.81;1;1;2;1],100,10,false)
% Or, simply call >> double_pendulum_init
%
function double_pendulum(ivp, duration, fps, movie)
%
---------------------------------------------------------------------
clear All; clf;
nframes=duration*fps;
sol=ode45(@double_pendulum_ODE,[0 duration], ivp);
t = linspace(0,duration,nframes);
y=deval(sol,t);
phi1=y(1,:)'; dtphi1=y(2,:)';
phi2=y(3,:)'; dtphi2=y(4,:)';
l1=ivp(8); l2=ivp(9);
% phi1=x(:,1); dtphi1=x(:,2);
% phi2=x(:,3); dtphi2=x(:,4);
% l1=ivp(8); l2=ivp(9);
h=plot(0,0,'MarkerSize',30,'Marker','.','LineWidth',2);
range=1.1*(l1+l2); axis([-range range -range range]); axis
square;
set(gca,'nextplot','replacechildren');
for i=1:length(phi1)-1
if (ishandle(h)==1)
Xcoord=[0,l1*sin(phi1(i)),l1*sin(phi1(i))+l2*sin(phi2(i))];
Ycoord=[0,-l1*cos(phi1(i)),-l1*cos(phi1(i))-l2*cos(phi2(i))];
set(h,'XData',Xcoord,'YData',Ycoord);
drawnow;
F(i) = getframe;
if movie==false
pause(t(i+1)-t(i));
end
end
end
if movie==true
movie2avi(F,'doublePendulumAnimation.avi','compression','Cinepak','fps',fps)
end
% Simply run
% >> double_pendulum_init
%This script calls double_pendulum.
%
%
---------------------------------------------------------------------
phi1 = pi;
dtphi1 = 0;
phi2 = pi;
dtphi2 = 5;
g = 9.81;
m1 = 1;
m2 = 1;
l1 = 2;
l2 = 1;
duration = 100;
fps = 10;
movie = true;
clc; figure;
interval=[0, duration];
ivp=[phi1; dtphi1; phi2; dtphi2; g; m1; m2; l1; l2];
double_pendulum(ivp, duration, fps, movie);
% This function calls is called by double_pendulum.
% ---------------------------------------------------------------------
function xdot = double_pendulum_ODE(t,x)
g=x(5); m1=x(6); m2=x(7); l1=x(8); l2=x(9);
xdot=zeros(9,1);
xdot(1)=x(2);
xdot(2)=-((g*(2*m1+m2)sin(x(1))+m2(g*sin(x(1)-2*x(3))+2*(l2*x(4)^2+...
l1*x(2)^2*cos(x(1)-x(3)))*sin(x(1)-x(3))))/...
(2*l1*(m1+m2-m2*cos(x(1)-x(3))^2)));
xdot(3)=x(4);
xdot(4)=(((m1+m2)(l1*x(2)^2+g*cos(x(1)))+l2*m2*x(4)^2*cos(x(1)-x(3)))...
sin(x(1)-x(3)))/(l2*(m1+m2-m2*cos(x(1)-x(3))^2));
Solving digital system problems using MATLAB Write a MATLAB script CTask2p3.m to: a) Generate the truth table for the following Boolean expressions and display it in the MATLAB command window (Use logical functions: and, not, or)
PROBLEM 2 Write a Matlab code* (script) or use Excel to determine the damping coefficient of a spring - mass - damper system with a mass of 165 kg and stiffness of 2400 N/m such that its response will die out (decay) after about 1.5 s, given a zero initial position and an initial velocity of 8 mm/s. 1. Display the numerical value of the damping coefficient. 2. Plot the response of the system. *Turn in your Matlab code with...
In matlab script, thank you!
Write a MATLAB script that will generate random integers in the range from 1 to 100, and print them, until one is finally generated that is greater than 50. The script should print how many attempts it took
Write a MATLAB script to plot the function of f(x) given by:
Write a MATLAB script to plot the function of f(x) given by: f(x) = integral x^2 - pi^2/4 x > pi/2 8 * cos x -pi/2 lessthanorequalto x lessthanorequalto pi/2 pi^2/4 - x^2 x < -pi/2
Solve the question in Matlab and please show Matlab code
Consider a double Spring-Mass-Damper System as shown in the figure below: U >F(t) A. Create a Simulink model to simulate the dynamics of the above system for the following parameter values: F(t) = Step input force of magnitude 5 N ml = 7 kg, b1 = 3 Nsec/m, kl = 4 N/m m2 = 3 kg, b2 = 1 Nsec/m, k2= 2 N/m B. Submit a snapshot of the Simulink...
Write a matlab script(using only matlab) for this.
Write a script to solve the following problem: Ask the user for the length and the width of a rectangle. These need to be passed to a function. The function is to calculate and return the area and the perimeter of the rectangle. The area is the length times the width and the perimeter is 2 times the length and 2 times the width. Make sure to suppress all output from the...
Using the "Newton's Method" Write a MATLAB script to solve for the following nonlinear system of equations: x2 + y2 + z2 = 3 x2 + y2 - z = 1 x + y + z =3 using the initial guess (x,y,z) = (1,0,1), tolerance tol = 1e-7, and maximum number of iterations maxiter = 20.
matlab script
QUESTION 1 (1) Write a MATLAB script to find the standard deviation of integer numbers located in the vector a. Note that the vector contains both integer and floating- point numbers. The standard deviation formula is: 1 S = VN-12(%; – T)? use a-[6.6, 3, 8, 5, 8.8, 54, 78, 90, 5.5] the result should be
Write a MATLAB script that loads and displays each of the captured images. Publish the MATLAB script output as a .docx file. For compactness purposes, show all five waveforms for each case on the same figure using MATLAB subplots. Use the legend function in MATLAB to add appropriate labeling to the subplots to ensure that the Figure legend can be written succinctly.
submitting Script files and function files
3. Write MATLAB code to solve the following system of linear equations. Display the value of each variable (eg. "x= 1, y = 2, and z = 3). (15 points) hy - 4z=6 5x - 7y + 3z--2 x - 2y = 0