Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab Plotting error I keep getting this error when I run my program Error using plot Vectors must be the same length. Error in untitled8

Matlab Plotting error

I keep getting this error when I run my program

Error using plot Vectors must be the same length.

Error in untitled8 (line 80)

subplot(2,1,1),plot(t,position)

Here is a copy of the code

clear all

a = 6652.555663;

e = 0.075;

i = deg2rad(28.5);

OMEGA = deg2rad(40);

omega = deg2rad(30);

nu = deg2rad(0);

u = 3.986e5;

r = (a*(1-e^2))/(1+e*cos(nu));

rp = [r*cos(nu) r*sin(nu)];

vp = [-sqrt(u/(a*(1-e^2)))*sin(nu) sqrt(u/(a*(1-e^2)))*(e+cos(nu))];

Q11 = -sin(OMEGA)*cos(i)*sin(omega) + cos(OMEGA)*cos(omega);

Q12 = cos(OMEGA)*cos(i)*sin(omega) + sin(OMEGA)*cos(omega);

Q13 = sin(i)*sin(omega);

Q21 = -sin(OMEGA)*cos(i)*cos(omega) - cos(OMEGA)*sin(omega);

Q22 = cos(OMEGA)*cos(i)*cos(omega) - sin(OMEGA)*sin(omega);

Q23 = sin(i)*cos(omega);

Q31 = sin(OMEGA)*sin(i);

Q32 = -cos(OMEGA)*sin(i);

Q33 = cos(i);

Q = [Q11 Q12 Q13;Q21 Q22 Q23;Q31 Q32 Q33]';

rp=[rp 0]';

vp = [vp 0]';

r = Q*rp;

v = Q*vp;

N = 540;

a = 0;

b = 5400;

h = (b-a)/N;

t = a;

w = [r(1);r(2);r(3);v(1);v(2);v(3)];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for plot?

n = numel(1:10:5400) + 1;

position = zeros(3,n);

velocity = zeros(3,n);

m = 1;

position(:,1) = w(1:3);

velocity(:,1) = w(4:6);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i = 1:10:5400

k1 = h*rky(t,w)

k2 = h*rky(t+h/2,w+k1/2);

k3 = h*rky(t+h/2,w+k2/2);

k4 = h*rky(t+h,w+k3);

w = w + (1/6)*(k1+k2+k3+k4)

t = a+i*h

end

for t = 1:10:5400

k1 = h*rky(t,w);

k2 = h*rky(t+h/2,w+k1/2);

k3 = h*rky(t+h/2,w+k2/2);

k4 = h*rky(t+h,w+k3);

w = w + (h/6)*(k1+2*k2+2*k3+k4);

t = t+h;

position = [w(1);w(2);w(3)];

velocity = [w(4);w(5);w(6)];

%%%%%%%%%%%%%%%%%%%%%?

m = m + 1;

position(:,m) = w(1:3);

velocity(:,m) = w(4:6);

%%%%%%%%%%%%%%%%%%%%%%%

end

subplot(2,2,1),plot(t,position)

title('position');

xlabel('Time');

ylabel('Displacement');

axis([1 5400 0 10000]);

subplot(2,2,2),plot(t,velocity)

title('velocity');

xlabel('Time');

ylabel('Displacement');

axis([1 5400 0 5]);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

What is IFRS?

Answered: 1 week ago