Coding Notes
Coding Notes
>> plot(x,y)
>> x = linspace(0,360,25); y = sind(x);
>> plot(x,y,'-gp')
>>
>> x = 0:25; y = sqrt(x);
>> plot(x,y,'ob:')
>>
>> x = 0:10; y = 5*x-3;
>> plot(x,y,'--kd','LineWidth',3,'MarkerSize',10,'MarkerEdgeColor',r, 'MarkerFaceColor','g')
error: 'r' undefined near line 1, column 65
>> plot(x,y,'--kd','LineWidth',3,'MarkerSize',10,'MarkerEdgeColor','r', 'MarkerFaceColor','g')
@(x) f (x)
>> axis([0,15,0,5])
>> axis equal
>> axis squar
warning: axis: unknown option 'squar'
warning: called from
axis>__axis__ at line 363 column 9
axis at line 179 column 7
>> subplot(2,1,1)
>> fplot(myfunc,[-3,4])
error: 'myfunc' undefined near line 1, column 7
>> fplot(my_func,[-3,4])
>> subplot(2,1,2)
>> fplot(my_func,[0,1])
>>
my_func = @(x) (x.^2 - 6*x +7)./(x.^3-8);
>> x1 = 0:0.1:1.9; x2 = 2.1:0.1:4;
>> y1 = my_func(x1); y2 = my_func(x2);
>> plot(x1,y1,x2,y2)
>>x = linespace(-pi,2*pi,100);
error: 'linespace' undefined near line 1, column 5
>> x = linspace(-pi,2*pi,100);
>> f = sin(2*x).*cos(0.5*x).^2
f=
df
error: 'df' undefined near line 1, column 1
>> diff(f)
>>
>> derv(f)
error: 'derv' undefined near line 1, column 1
>> f
f=
>> df = diff(f,1)
df =
>> f(100)=[]
f=
1 4 7 10 13 16 19 22 25 28 31 34
>> B = 1:3:34
B=
1 4 7 10 13 16 19 22 25 28 31 34
>> C = linspace(0,12,11)
C=
0 1.2000 2.4000 3.6000 4.8000 6.0000 7.2000 8.4000 9.6000 10.8000 12.0000
syntax error
>>> u= {w v]
^
>> u = [w v]
u=
17 21 25 29 33 37 41 38 35 32 29
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
>> C = linspace(1,5,5)
C=
1 2 3 4 5
>> linspace(6,10,5)
ans =
6 7 8 9 10
>> A = zeros(3,5)
A=
>> B = ones(5,2)
B=
>> D = eye(3)
D=
Diagonal Matrix
>> D = eye(3,5)
D=
Diagonal Matrix
>> '
error: parse error:
t = linspace(0, 4, 100);
>> x = 4.219*(exp(-1.58*t)-exp(-6.32*t));
>> v = 26.67*exp(-6.32*t)-6.67*exp(-1.58*t);
>>
>> subplot(2,1,1)
>> plot(t,x)
>> xlabel('time (s)')
>> ylabel('position (m)')
>> subplot(2,1,2)
>> plot(t,v)
>> xlabel('time (s)')
>> ylabel('velocity (m/s)')
>>
>>
>> x1 = 0:0.1:8;
>> x2 = 8:0.1:12;
>> x3 = 12:0.1:20;
>> Va = 400 -200*x1;
>> Vb(1:length(x2))=-1200;
>> Vc=-250*x3+5000;
>> Ma =-100*x1.^2+400*x1;
>> Mb =-1200*x2+6400;
>> Mc =-125*(x3-12).^2+2000*x3-32000;
>>
>> x = [x1 x2 x3];
>> V = [Va Vb Vc];
>> M = [Ma Mb Mc];
>>
>> subplot(2,1,1)
>> plot(x,V)
>> xlabel('x (ft)')
>> ylabel('Shear Force (lb)')
>> subplot(2,1,2)
>> plot(x,M)
>> xlabel('x (ft)')
>> ylabel('Bending Moment (lb-ft)')