CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 06:05:24 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=25f6a84a293cdedcda624d30ca377b08d682bed262e01cd1f5ae88f8bb4321c0a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22LDGZ0k2pHDlsoobijkA__6TUPo33_TiZ%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cc2a60ba49cf00-BLR
plotProjectile MatLab Function - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [y_values] = plotProjectile(vi, p_angle, t_values)
- syms t
- g = 9.81;
- % y = vi * sin(alpha)t - 0.5*g(t^2)
- y(t) = vi * sind(p_angle) * t - 0.5 * g * (t^2);
- y_values = double(subs(y, t, t_values));
- plot(t_values, y_values, "Color", [1,0,0], "Marker","square");
- ylim([0 max(y_values)]);
- xlim([0 max(t_values)]);
- title("Projectile Motion with Tangent Vectors");
- xlabel("Time (seconds)");
- ylabel("Height (meters)");
- hold on
- % Getting derivative of y with respect to time to draw tanjent lines
- dy_dt = diff(y, t);
- dy_dt_values = double(subs(dy_dt, t, t_values));
- line_length = (t_values(2) - t_values(1));
- % Offset variable to make the text a little bit away from the
- % main graph to avoid overlapping
- vertical_offset = 0.2;
- for i = 1:length(t_values)
- %{
- Both the vectors y, t have the same size, so we can get y(t)
- values at each drawn point by using index of that element in
- vector, which I called ( i ) in my example.
- %}
- t0 = t_values(i);
- y0 = y_values(i);
- slope = dy_dt_values(i);
- %{
- line length should be equal square root of (dx)^2 + (dy)^2
- and dy = slope * dx where slope = dy/dx
- therefore line length = dx * square root of (1 + slope^2)
- and multiplied by 5 for scaling on the plot
- %}
- dx = (line_length * 5 / sqrt(1 + slope^2));
- quiver(t0, y0 , dx, slope * dx, 'b', 'LineWidth', 1, 'MaxHeadSize', 0.5);
- text(t0, y0 + vertical_offset, sprintf('v = %.2f', slope), ...
- 'FontSize', 8, 'Color', 'blue');
- % Drawing vertical and horizontal at each point
- quiver(t0, y0, 0, dx * slope, 'k', 'LineWidth', 1, 'MaxHeadSize', 0.5);
- quiver(t0, y0, dx, 0, 'k', 'LineWidth', 1, 'MaxHeadSize', 0.5);
- end
- legend("Projectile Path", "Tangent Vectors (V)", "Vertical and Horizontal Components");
- hold off
- end
Advertisement
Add Comment
Please, Sign In to add comment
-
✅ Make $2500 in 20 minutes⭐⭐⭐ H
JavaScript | 4 sec ago | 0.24 KB
-
⭐⭐⭐Free Giftcards Method⭐⭐
Java | 4 sec ago | 0.10 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 6 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ M
JavaScript | 15 sec ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 15 sec ago | 0.24 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 16 sec ago | 0.10 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 24 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ 4
JavaScript | 26 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand