Question
Trouble labeling the lines on my MatLab plot I need to make my graph look like this: here is my code: close all clear all
Trouble labeling the lines on my MatLab plot
I need to make my graph look like this: here is my code:
close all
clear all
clc
%%defining variables
dt = .001;
numberOfCalculations = 10000;
velocityX(1) = 70 * .44704 %mph to m/s
velocityY(1) = 0;
velocityZ(1) = 0;
positionX(1) = 0;
positionY(1) = 3.5*.3048;
positionZ(1) = 0;
Bm = 1;
g = 9.81;
Som = 4.1 * 10^(-4);
w = 30*2*3.14; %rad/s
mass = 149/1000;
So = Som * mass;
delta = 5;
vd = 35;
t=1
K = zeros(4);
L = zeros(4);
M = zeros(4);
N = zeros(4);
P = zeros(4);
Q = zeros(4);
for t = 1:numberOfCalculations
for i = 2:5
velocity = sqrt(velocityX(t)^2 + velocityY(t)^2 + velocityZ(t)^2);
Bm = .0039 + (.0058)/(1+exp((velocity-vd)/delta));
% K(i) = h * velocityX(i);
K(i) = dt * (velocityX(t) + (L(i-1)/2));
%L(i) = h(-Bm)*sqrt( velocityX(i)^2 + velocityY(i)^2 + velocityZ(i)^2) * velocityX(i);
L(i) = dt*(-Bm)*sqrt( (velocityX(t) + (L(i-1)/2))^2 + (velocityY(t) + (N(i-1)/2))^2 + (velocityZ(t) + (Q(i-1)/2))^2) * (velocityX(t)+(L(i-1)/2));
%M(i) = h * velocityY(i);
M(i) = dt * (velocityY(t) + (N(i-1)/2));
%N(i) = -h * g;
N(i) = -dt * g;
%P(i) = h * velocityZ(i);
P(i) = dt * (velocityZ(t) + (Q(i-1)/2));
%Q(i) = h * ((-So * w)/(m)) * velocityX(i);
Q(i) = dt * ((-So * w)/(mass)) * (velocityX(t) + (L(i-1)/2));
end
positionX(t+1) = positionX(t) + (1/6) * (K(2) + 2 * K(3) + 2 * K(4) + K(5));
velocityX(t+1) = velocityX(t) + (1/6) * (L(2) + 2 * L(3) + 2 * L(4) + L(5));
positionY(t+1) = positionY(t) + (1/6) * (M(2) + 2 * M(3) + 2 * M(4) + M(5));
velocityY(t+1) = velocityY(t) + (1/6) * (N(2) + 2 * N(3) + 2 * N(4) + N(5));
positionZ(t+1) = positionZ(t) + (1/6) * (P(2) + 2 * P(3) + 2 * P(4) + P(5));
velocityZ(t+1) = velocityZ(t) + (1/6) * (Q(2) + 2 * Q(3) + 2 * Q(4) + Q(5));
if positionX(t) >= 60
break
end
end
positionX = positionX/.3048;
positionY = positionY/.3048;
positionZ = positionZ/.3048;
%%Plots
figure(1)
hold on
box on
plot(positionX(1:631),positionY(1:631),':k', positionX(1:631),-positionZ(1:631),'-k')%Just index till where you want, does that work?
line([0 0], [-3.75 3.75], 'color', 'black', 'LineStyle', '--');
line([60 60], [-3.75 3.75], 'color', 'black', 'LineStyle', '--');
set(gca,'Xtick',linspace(0,60,4),'fontsize',18,'Ytick',linspace(-4,4,5))
set(gcf,'Color','w');
set(gcf,'Resize','on');
ylim([-4 4])
xlim([-10 70])
ylabel('y or z (feet)','fontsize',18)
xlabel ('x (feet)','fontsize',18)
text(t(300),positionX(300),'pitcher','fontsize',18)
text(t(100),positionX(1200),'horizontal deflection (z)','fontsize',18)
text(t(300),positionX(300),'vertical deflection','fontsize',18)
text(t(100),positionX(1200),'home plate','fontsize',18)
title('Sidearm curve ball','fontsize',19)
hold off
hold off
I tried various numbers for the position and I can't find the right ones. Can you put the arrows in too?
Sidearm curve ball 4 vertical deflection (y) 2 :horizontal deflection (z) pitcher home plate 0 20 40 60 x (feet)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started