can we make 3D mash plot from eq y(x)

조회 수: 3 (최근 30일)
nirwana
nirwana 2023년 3월 17일
답변: Walter Roberson 2023년 3월 17일
I have equation ball trajectory
y=(tand(theta)*x-(g/(2*v0^2*cosd(theta)^2)*x.^2)+y0
i wonder how to make mesh plot when i have no equation z(x,y)=...
i just think that 2D graph can make into 3D, so can i use z =linespace (....)
theta=50;
g=9.81;
v0=25;
y0=1;
fun=@(x) (-1)*(tand(theta)*x-(g/(2*v0^2*cosd(theta)^2)*x.^2)+y0);

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 3월 17일
You can consider the following code for 3D simulation of the projectile:
% Projectile motion simulation for t = [0 : 25] seconds
t = linspace(0, 25);
theta=50;
g=9.81;
V0=25; % Initial Velcoity in [m/s]
y0=1; % Distance in [m]
% Initial Conditions:
X0 = 0.0;
Y0 = 1.0;
Z0 = 0.0;
% initial velocity values [m/s]:
Vx0 = V0*cosd(theta)*sind(theta);
Vy0 = V0*sind(theta)*sind(theta);
Vz0 = V0*cosd(theta);
% Acceleration values [m/s^2]:
Ax0 = 0.0;
Ay0 = 0.0;
Az0 = -9.8;
x = X0 + Vx0*t + 0.5*Ax0*t.^2;
y = Y0 + Vy0*t + 0.5*Ay0*t.^2;
z = Z0 + Vz0*t + 0.5*Az0*t.^2;
% 3D plot
figure(1) % Animated plot
comet3(x,y,z)
figure(2)
plot3(x,y,z,'ro-','markerfacecolor', 'y')
grid on,
view([-30,55])
xlabel('Displacement along x [m]')
ylabel("Position along y [m]")
zlabel("Position along z [m]")
title("3D Projectile Motion Simulation")

Walter Roberson
Walter Roberson 2023년 3월 17일
syms x theta
g=9.81;
v0=25;
y0=1;
fun = (-1)*(tand(theta)*x-(g/(2*v0^2*cosd(theta)^2)*x.^2)+y0);
fsurf(fun, [0 300, 0 90])
xlabel('x'); ylabel('theta')

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by