answersLogoWhite

0

% Definitions

R2D = 180/pi; % rad to deg

D2R = pi/180; % deg to rad

F2M = 0.3040; % feet to meter

m = 45.46; % kg

g = -9.8; % gravity (m/s^2)

j = sqrt(-1);

dt = 0.001; %1000Hz

R1 = 15*F2M; %m

R2 = 15*F2M;

% Initial conditions

xBall = [0; 0]; % theta/omega

% Machine initial conditions

Torque = (-1)*m*g*R1; % N-m

Pmotor = 1119000; % W

Tbreak = (4404 / 0.738)*2.3; % break torque in N-m

% Ball

I = m*(R1^2);

for launch=0:1:20

times_launched = launch + 1;

% Main loop

iter = 0;

for time=0:dt:1

% Index

iter = iter + 1;

% Torque generation and check

if( (xBall(2,1)) < ((Pmotor)/Tbreak) )

Torque = Tbreak;

else

Torque = (Pmotor)/xBall(2,1);

end

% From 0 degrees to 90 degrees

if ((xBall(1,1)*R2D) >= 0 ) ((xBall(1,1)*R2D) < 90)

% Calculate net torque

Tgrav = ( m*g*cos(xBall(1,1)))*R1;

Tnet = Torque + Tgrav;

% Calculate instantaneous angular acceleration

alphaB = Tnet/I;

% Calculate the derivative of the state

xdot = [ xBall(2,1); alphaB ];

% Integration of the state

xBall = xBall + xdot*dt;

% Dependent states

pBall = R1*( cos(xBall(1,1)) + j*sin(xBall(1,1)) );

vBall = xBall(2,1) * R1;

Power = (Tnet/R1) * vBall;

elseif ( ((xBall(1,1)*R2D) >= 90) ((xBall(1,1)*R2D) <= 180) )

% Calculate net torque

Tgrav = ( m*g*cos( xBall(1,1)) )*R1;

Tnet = Torque + Tgrav;

% Calculate instantaneous angular acceleration

alphaB = Tnet/I;

% Calculate the derivative of the state

xdot = [ xBall(2,1); alphaB ];

% Integration of the state

xBall = xBall + xdot*dt;

% Dependent states

pBall = real(vBall) * time;

Power = (Tnet/R1) * vBall;

end;

DATA(iter,:) = [ iter time xBall' alphaB Tnet xBall(1,1)*R2D ...

real(pBall) imag(pBall) real(vBall) imag(vBall) vBall Power ];

end;

end;

%% Trajectory of Projectile (y vs. x)

figure(1);

plot( DATA(:,8), DATA(:,9), '.' );

title ('Trajectory (y vs. x) of projectile during launch')

xlabel('x')

ylabel('y')

%% Range (x) vs. time

figure(2);

subplot (211), plot(DATA(:,2), DATA(:,8), '.' );

title ('Range(x) as a function of time')

ylabel('Range(x)')

%% Altitude (y) vs. time

subplot (212), plot(DATA(:,2), DATA(:,9), '.' );

title ('Altitude(y) as a function of time')

xlabel('time')

ylabel('Altitude(y)')

%% Velocity (x and y components) vs. time

figure(3);

subplot (211), plot(DATA(:,2), DATA(:,10), '.' );

title ('Velocity (x and y) as a function of time')

ylabel('Velocity(x)')

subplot (212), plot(DATA(:,2), DATA(:,11), '.' );

xlabel('time')

ylabel('Velocity(y)')

%% Velocity (total) vs. time

figure(4);

plot(DATA(:,2), DATA(:,12), '.' );

title ('Velocity(total) as a function of time')

xlabel('time')

ylabel('Velocity (total))')

%% Power vs. time

figure(5);

plot(DATA(:,2), DATA(:,13), '.' );

title ('Power as a function of time')

xlabel('time')

ylabel('Power')

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How do you make graph from an equation in Matlab?

Initially, the equation can be directly realized using Matlab source code. Then various inputs can be applied to it. These values can easily be plotted on a graph using plot or stem command in Matlab.


How do you implement awgn in MATLAB without using awgn function?

no way... use awgn function in matlab


What has the author John G Proakis written?

John G. Proakis has written: 'Introduction to digital signal processing' -- subject(s): Signal processing, Digital techniques 'Digital signal processing' 'Contemporary communication systems using MATLAB and Simulink' -- subject(s): Computer simulation, Data transmission systems, MATLAB, Telecommunication systems


How do you call matlab from java?

You can MATLAB from Java by using the matlabcontrol library available at link1. A walkthrough to get you started can be found at link2


How can I create an effective wooden catapult design for a school project?

To create an effective wooden catapult design for a school project, follow these steps: Research different types of catapult designs to understand the principles behind their functionality. Choose a design that aligns with your project goals and materials available. Sketch out your design, including measurements and materials needed. Build the catapult using sturdy wooden materials and secure connections. Test the catapult with different projectiles to ensure it launches effectively. Make any necessary adjustments to improve performance. Present your catapult design, explaining the engineering principles behind its functionality.


Convolution in matlab using for loop?

There are a lot of convolution functions in matlab, mostly in the signal processing toolbox, so it depends on what you want to do. Matlab has extensive help files available online.


How can I calculate a double integral using the trapz function in MATLAB?

To calculate a double integral using the trapz function in MATLAB, you can first create a grid of points for the two variables you are integrating over. Then, evaluate the function you are integrating at these points to create a matrix of function values. Finally, use the trapz function twice - once along one dimension and then along the other dimension - to compute the double integral.


How can the wave equation be solved using MATLAB?

To solve the wave equation using MATLAB, you can use numerical methods such as finite difference or finite element methods. These methods involve discretizing the wave equation into a system of equations that can be solved using MATLAB's built-in functions for solving differential equations. By specifying the initial conditions and boundary conditions of the wave equation, you can simulate the behavior of the wave over time using MATLAB.


How can I programmatically stop a MATLAB script execution using a single command in MATLAB?

To programmatically stop a MATLAB script execution using a single command, you can use the &quot;return&quot; command. This command will immediately exit the current function or script, effectively stopping its execution.


How do you modulate in matlab without using matlab tools?

You would have to write your own code for a modulation (Matlab has a convolution function not in the tools), otherwise you can use its built in function in the signal processing toolbox.


Are there Mouse trap catapult blueprints?

Yes, there are various blueprints and instructions available online for building a mouse trap catapult. These designs typically involve using common household items along with a mouse trap to create a miniature catapult for fun or experimentation purposes. Just be mindful of safety precautions while building and handling the catapult.


What is a sentence using the word catapult?

The medieval army used a catapult to launch large stones at the enemy's castle walls.