Everytime I run code the color of lines on my graph changes
load ENGR131_lab4_Data.mat
function h = CalcPosition(t,DC,w)
wn=1.8
o=DC.*wn;
h=1-exp(-o.*t).*cos(w.*t);
end
function x = five(t,N,V,h,w)
z=evalin(‘base’,’DC’)
for N=1:2
switch N
case 1
plot(t,h)
hold on
case 2
plot(t,h);
hold on
case 3
LineColor=’k-‘;
plot(t,h,’:’);
hold on
case 4
LineColor= ‘m-‘;
plot(t,h,’-.’);
hold on
end
end
end
for V=1
subplot(2,3,V)
t=linspace(0,20,100)
for N=1:2
figure(1)
h=CalcPosition(t,DC(1,N),w(1,V))
five(t,N,V,h,w)
end
endload ENGR131_lab4_Data.mat
function h = CalcPosition(t,DC,w)
wn=1.8
o=DC.*wn;
h=1-exp(-o.*t).*cos(w.*t);
end
function x = five(t,N,V,h,w)
z=evalin(‘base’,’DC’)
for N=1:2
switch N
case 1
plot(t,h)
hold on
case 2
plot(t,h);
hold on
case 3
LineColor=’k-‘;
plot(t,h,’:’);
hold on
case 4
LineColor= ‘m-‘;
plot(t,h,’-.’);
hold on
end
end
end
for V=1
subplot(2,3,V)
t=linspace(0,20,100)
for N=1:2
figure(1)
h=CalcPosition(t,DC(1,N),w(1,V))
five(t,N,V,h,w)
end
end load ENGR131_lab4_Data.mat
function h = CalcPosition(t,DC,w)
wn=1.8
o=DC.*wn;
h=1-exp(-o.*t).*cos(w.*t);
end
function x = five(t,N,V,h,w)
z=evalin(‘base’,’DC’)
for N=1:2
switch N
case 1
plot(t,h)
hold on
case 2
plot(t,h);
hold on
case 3
LineColor=’k-‘;
plot(t,h,’:’);
hold on
case 4
LineColor= ‘m-‘;
plot(t,h,’-.’);
hold on
end
end
end
for V=1
subplot(2,3,V)
t=linspace(0,20,100)
for N=1:2
figure(1)
h=CalcPosition(t,DC(1,N),w(1,V))
five(t,N,V,h,w)
end
end graphing MATLAB Answers — New Questions