Displacement Graph (How to center it) ?
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone.
I am new to MatLab and I am working on a code which is supposed to calculated the displacement of the aircraft from top view.
I have managed to write the code and plot X and Y coordinates which look like this (Picture below)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/288080/image.png)
I would like to center the graph. What I mean by that is I want 0 Y coordinate to be in the middle of the circle and not at the bottom. I would really appreciate any help!
Here is the code:
clc;
clear all;
close all;
M = 8000; % Mass of the plane (kg)
V = 80; %Velocity (m/s)
R = 250; %Radius of the turn (m)
g = 9.81; %Gravitaional Acceleration (m/s)
thetaDeg = 0;
w = V/R %Angular velocity
W = g*M %Weight of the plane. (N)
%solve 360turn equation to find max t
t360 = 2*(pi/w)
dt = 0.1; %time step
t = 0:dt:t360;
%find n and theta
n = sqrt((V^2/(R*g))^2+1)
thetaRad = acos(1/n)
thetaDeg = (thetaRad/pi)*180
F = W*n*sin(thetaRad)
%Vx = zeros(1,length(t));
%Vy = zeros(1,length(t));
%Xp = zeros(1,length(t));
%Yp = zeros(1,length(t));
Vx = V*sin(thetaRad);
Vy = V*sin(thetaRad);
Xc = zeros(1,20);
Yc = zeros(1,20);
Xc(1) = 0;
Yc(1) = 0;
Crs = zeros(1,length(t));
Crs(1) = 0
CrsDeg = zeros(1,length(t));
CrsDeg(1) = 0
for n=2:length(t)
Crs(n) = Crs(n-1)+(w*dt)
Yc(n) = Yc(n-1)+(dt*Vy*sin(Crs(n)))
Xc(n) = Xc(n-1)+(dt*Vx*cos(Crs(n)))
CrsDeg(n) = (Crs(n)/pi)*180
end
plot(Xc,Yc)
%rad = pi*theta/180;
% L = cos(th) = W
% L = nW
% cos(th) = (1/n)
0 个评论
回答(2 个)
Srivardhan Gadila
2020-4-30
If your concern is regarding the plot only then the quick work around would be to replace
plot(Xc,Yc)
with
plot(Xc,Yc-max(Yc)/2)
If this is not what you are looking for, then can you explain the issue more specifically?
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!