Created
November 4, 2013 04:59
-
-
Save jpace121/7298244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [ output_args ] = MechSys89( input_args ) | |
| %Promblem 8-9 | |
| B = [0;0;0;1]; | |
| A = [ 1 1 1 1; 3 4 5 6; 6 12 20 30; .25^3 .25^4 .25^5 .25^6]; | |
| C = A\B; | |
| C = [0;0;0;C]; %'cause C(1) and stuff don't exist | |
| beta = 180; | |
| s = @(t) C(3)*(t/beta)^3+C(4)*(t/beta)^4+C(5)*(t/beta)^5+C(6)*(t/beta)^6; | |
| v = @(t) (1/beta)*(3*C(3)*(t/beta)^2 + 4*C(4)*(t/beta)^3 + 5*C(5)*(t/beta)^4 + 6*C(6)*(t/beta)^5); | |
| a = @(t) (1/beta^2)*(6*C(3)*(t/beta) + 12*C(4)*(t/beta)^4 + 20*C(5)*(t/beta)^3 + 30*C(6)*(t/beta)^4); | |
| j = @(t) (1/beta^3)*(6*C(3) + 24*C(4)*(t/beta) + 60*C(5)*(t/beta)^2 + 120*C(6)*(t/beta)^3); | |
| theta = 0:1:360; | |
| POS = zeros(numel(theta)); VEL = zeros(numel(theta)); ACC = zeros(numel(theta)); JER = zeros(numel(theta)); | |
| %only evaluate functions while theta is in the range between 0 and 180, | |
| %else leave it alone at 0 | |
| for t = 1:1:360 | |
| POS(t) = s(t); | |
| VEL(t) = v(t); | |
| ACC(t) = a(t); | |
| JER(t) = j(t); | |
| end | |
| figure(1) | |
| subplot(4,1,1) | |
| plot(theta,POS) | |
| subplot(4,1,2) | |
| plot(theta,VEL) | |
| subplot(4,1,3) | |
| plot(theta,ACC) | |
| subplot(4,1,4) | |
| plot(theta,JER) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment