k=1
k =
1
omega1=fzero(@(x) freqEq(x,k), 0.5*pi)
omega1 =
2.0288
fprintf('The lowest frequency for k = %i is: %7.4f\n',k,omega1)
The lowest frequency for k = 1 is: 2.0288
tMeasured = [0 0.5 1 1.5 2]
tMeasured =
0 0.5000 1.0000 1.5000 2.0000
TMeasured=[14.6 8.42 4.86 2.8 1.62]
TMeasured =
14.6000 8.4200 4.8600 2.8000 1.6200
TExactFun = @(t) 14.6*exp(-1.1*t);
tPlot=linspace(0,2,100)';
tPlot
tPlot =
0
0.0202
0.0404
0.0606
0.0808
0.1010
0.1212
0.1414
0.1616
0.1818
0.2020
0.2222
0.2424
0.2626
0.2828
0.3030
0.3232
0.3434
0.3636
0.3838
0.4040
0.4242
0.4444
0.4646
0.4848
0.5051
0.5253
0.5455
0.5657
0.5859
0.6061
0.6263
0.6465
0.6667
0.6869
0.7071
0.7273
0.7475
0.7677
0.7879
0.8081
0.8283
0.8485
0.8687
0.8889
0.9091
0.9293
0.9495
0.9697
0.9899
1.0101
1.0303
1.0505
1.0707
1.0909
1.1111
1.1313
1.1515
1.1717
1.1919
1.2121
1.2323
1.2525
1.2727
1.2929
1.3131
1.3333
1.3535
1.3737
1.3939
1.4141
1.4343
1.4545
1.4747
1.4949
1.5152
1.5354
1.5556
1.5758
1.5960
1.6162
1.6364
1.6566
1.6768
1.6970
1.7172
1.7374
1.7576
1.7778
1.7980
1.8182
1.8384
1.8586
1.8788
1.8990
1.9192
1.9394
1.9596
1.9798
2.0000
tPlot=linspace(0,2,100)';
TExactPlot=TExactFun(tPlot);
TExactPlot
TExactPlot =
14.6000
14.2791
13.9653
13.6584
13.3582
13.0647
12.7775
12.4967
12.2221
11.9535
11.6908
11.4338
11.1826
10.9368
10.6964
10.4614
10.2314
10.0066
9.7867
9.5716
9.3612
9.1555
8.9543
8.7575
8.5650
8.3768
8.1927
8.0126
7.8366
7.6643
7.4959
7.3312
7.1700
7.0125
6.8583
6.7076
6.5602
6.4160
6.2750
6.1371
6.0022
5.8703
5.7413
5.6151
5.4917
5.3710
5.2530
5.1376
5.0246
4.9142
4.8062
4.7006
4.5973
4.4963
4.3974
4.3008
4.2063
4.1138
4.0234
3.9350
3.8485
3.7639
3.6812
3.6003
3.5212
3.4438
3.3681
3.2941
3.2217
3.1509
3.0817
3.0139
2.9477
2.8829
2.8195
2.7576
2.6970
2.6377
2.5797
2.5230
2.4676
2.4134
2.3603
2.3085
2.2577
2.2081
2.1596
2.1121
2.0657
2.0203
1.9759
1.9325
1.8900
1.8485
1.8078
1.7681
1.7293
1.6912
1.6541
1.6177
TExactPlot=TExactFun(tPlot);
plot(tPlot,TExactPlot,':k;Exact;',tMeasured,TMeasured,'om;Measured;')
{Error using plot
Error in color/linetype argument.}
plot(tPlot,TExactPlot,':k;Exact;',tMeasured,TMeasured,)
plot(tPlot,TExactPlot,':k;Exact;',tMeasured,TMeasured,)
{Error: Unbalanced or unexpected parenthesis or bracket.
}
plot(tPlot,TExactPlot,':k;Exact;',tMeasured,TMeasured)
{Error using plot
Error in color/linetype argument.}
plot(tPlot,TExactPlot,tMeasured,TMeasured,'om;Measured;')
{Error using plot
Error in color/linetype argument.}
help plot
plot Linear plot.
plot(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, disconnected
line objects are created and plotted as discrete points vertically at
X.
plot(Y) plots the columns of Y versus their index.
If Y is complex, plot(Y) is equivalent to plot(real(Y),imag(Y)).
In all other uses of plot, the imaginary part is ignored.
Various line types, plot symbols and colors may be obtained with
plot(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, plot(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; plot(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.
plot(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X's and Y's are vectors or matrices
and the S's are strings.
For example, plot(X,Y,'y-',X,Y,'go') plots the data twice, with a
solid yellow line interpolating green circles at the data points.
The plot command, if no color is specified, makes automatic use of
the colors specified by the axes ColorOrder property. By default,
plot cycles through the colors in the ColorOrder property. For
monochrome systems, plot cycles over the axes LineStyleOrder property.
Note that RGB colors in the ColorOrder property may differ from
similarly-named colors in the (X,Y,S) triples. For example, the
second axes ColorOrder property is medium green with RGB [0 .5 0],
while plot(X,Y,'g') plots a green line with RGB [0 1 0].
If you do not specify a marker type, plot uses no marker.
If you do not specify a line style, plot uses a solid line.
plot(AX,...) plots into the axes with handle AX.
plot returns a column vector of handles to lineseries objects, one
handle per plotted line.
The X,Y pairs, or X,Y,S triples, can be followed by
parameter/value pairs to specify additional properties
of the lines. For example, plot(X,Y,'LineWidth',2,'Color',[.6 0 0])
will create a plot with a dark red line width of 2 points.
Example
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
plot(x,y,'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
See also plottools, semilogx, semilogy, loglog, plotyy, plot3, grid,
title, xlabel, ylabel, axis, axes, hold, legend, subplot, scatter.
Reference page for plot
Other functions named plot
plot(tPlot,TExactPlot,'k:;Exact;',tMeasured,TMeasured,'mo;Measured;')
{Error using plot
Error in color/linetype argument.}
plot(tPlot,TExactPlot,';Exact;',tMeasured,TMeasured,';Measured;')
{Error using plot
Error in color/linetype argument.}
plot(tPlot,TExactPlot,'k:',tMeasured,TMeasured,'mo')
t=0.7
t =
0.7000
TLinear=interp1(tMeasured,TMeasured,0.7)
TLinear =
6.9960
TSpline=spline(tMeasured,TMeasured,0.7)
TSpline =
6.7513
TExactFun(0.7)
ans =
6.7600
TLinearPlot=interp1(tMeasured,TMeasured,tPlot);
TSplinePlot=spline(tMeasured,TMeasured,tPlot);
plot(tPlot,TExactPlot,'k:',tMeasured,TMeasured,'mo',...tPlot,TLinearPlot,'r',tPlot,TSplinePlot)
{Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
}
plot(tPlot,TExactPlot,'k:',tMeasured,TMeasured,'mo',...tPlot,TLinearPlot,'r',tPlot,TSplinePlot)
plot(tPlot,TExactPlot,'k:',tMeasured,TMeasured,'mo',...
tPlot,TLinearPlot,'r',tPlot,TSplinePlot)
tPlot,TLinearPlot,'r',tPlot,TSplinePlot)
{Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
}
plot(tPlot,TExactPlot,'k:',tMeasured,TMeasured,'mo',...
tPlot,TLinearPlot,'r',tPlot,TSplinePlot,'b')
t=5
t =
5
TSpline=spline(tMeasured,TMeasured,t)
TSpline =
-14.7000
TExactFun(t)
ans =
0.0597
TLinear=interp1(tMeasured,TMeasured,5)
TLinear =
NaN
TLinear=interp1(tMeasured,TMeasured,5,'extrap')
{Error using interp1>parseinputs (line 388)
An interpolation method must be specified with 'extrap'.
Error in interp1 (line 80)
[method,extrapval,ndataarg,pp] = parseinputs(varargin{:});}
TLinear=interp1(tMeasured,TMeasured,5,'linear','extrap')
TLinear =
-5.4600
plot(tPlot,TExactPlot,'k:',tMeasured,TMeasured,'mo',...
tPlot,TLinearPlot,'r',tPlot,TSplinePlot,'b')
t=5;
TLinear=interp1(tMeasured,TMeasured,5,'linear','extrap');
TSpline=spline(tMeasured,TMeasured,t);