initialVel = 5; angle = 30; timeInc = .1; endTime = 1;
[times,horzPos,vertPos] = Projectile(initialVel,angle,timeInc,endTime);
fig1 = figure(1);
plot(horzPos,vertPos)
title('Projectile')
xlabel('horizontal position');
ylabel('vertical position');
xlabel('horizontal position (m)');
ylabel('vertical position (m)');
axis([0 4 -2 0])
plot(1:10)
plot(10:5:50)
x = 0:.1:1
x =
Columns 1 through 7
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000
Columns 8 through 11
0.7000 0.8000 0.9000 1.0000
y = exp(x)
y =
Columns 1 through 7
1.0000 1.1052 1.2214 1.3499 1.4918 1.6487 1.8221
Columns 8 through 11
2.0138 2.2255 2.4596 2.7183
plot(x,y)
semilogy(x,y)
loglog(x,y)
stairs(x,y)
plot(horzPos,vertPos)
grid on
grid off
gtext('maximum height')
text(2,-1,'point')
ginput(1)
ans =
2.5144 -0.2412
ginput(3)
ans =
0.4821 -1.0132
2.7944 -0.4254
2.1930 -1.9781
ginput()
ans =
1.2909 -0.4781
4.0075 -0.5570
3.3646 -1.1974
1.6953 0.1974
0.5547 -1.9868
3.9556 -1.6886
3.9556 -0.7500
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.
Overloaded methods:
timeseries/plot
Reference page in Help browser
doc plot
plot(horzPos,vertPos)
plot(horzPos,vertPos,'r')
plot(horzPos,vertPos,'k')
plot(horzPos,vertPos,'ko')
plot(horzPos,vertPos,'-ko')
plot(horzPos,vertPos,'-kp')
plot(horzPos,vertPos,'-k.')
plot(horzPos,vertPos,':k.')
plot(horzPos,vertPos,'-.k.')
plot(horzPos,vertPos,'--.k.')
{Error using plot
Error in color/linetype argument
}
plot(horzPos,vertPos,'--k.')
plot(horzPos,vertPos,'m<')
ginput(4)
ans =
0.3370 -1.1974
1.9130 0.1447
1.8612 -1.0482
1.8508 -0.8640
[times,horzPos60,vertPos60] = Projectile(initialVel,60,timeInc,endTime);
plot(horzPos,vertPos,'-m<')
hold on
plot(horzPos60,vertPos60,'-kd')
hold off
plot(horzPos,vertPos,'-m<',horzPos60,vertPos60,'-kd')
figure(1)
subplot(2,3,1)
plot(horzPos,vertPos,'-m<')
subplot(2,3,2)
plot(horzPos,vertPos,':yh')
subplot(2,3,3)
plot(horzPos,vertPos,':k')
subplot(2,3,4)
plot(horzPos,vertPos,':k')
subplot(2,3,5)
plot(horzPos,vertPos,'--b')
subplot(2,3,6)
plot(horzPos,vertPos,'--b')
title('figure 6')
subplot(2,3,1)
title('figure 1')
plot(horzPos,vertPos,'--b','LineWidth',5)
plot(horzPos,vertPos,'--b','LineWidth',1)
plot(horzPos,vertPos,'--b','LineWidth',2)
plot(horzPos,vertPos,'--b','LineWidth',2,'MarkerEdgeColor','g')
plot(horzPos,vertPos,'--bd','LineWidth',2,'MarkerEdgeColor','g')
plot(horzPos,vertPos,'--bd','LineWidth',2,'MarkerEdgeColor','g','MarkerSize',10)
plot(horzPos,vertPos,'--bd','LineWidth',2,'MarkerEdgeColor','g','MarkerSize',20)
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, ==
Matrix dimensions must agree.
}
strcmp(myString1,myString2)
ans =
0
myString1
myString1 =
Tamar
lower(myString1)
ans =
tamar
upper(myString1)
ans =
TAMAR
myFirstName = 'Tamar'
myFirstName =
Tamar
myLastName = 'Shinar'
myLastName =
Shinar
myFullName = [ myFirstName, ' ', myLastName ]
myFullName =
Tamar Shinar
strcat(myFirstName,myLastName)
ans =
TamarShinar
myFirstName = 'Tamar '
myFirstName =
Tamar
strcat(myFirstName,myLastName)
ans =
TamarShinar
myLastName = ' Shinar'
myLastName =
Shinar
strcat(myFirstName,myLastName)
ans =
Tamar Shinar
blanks(10)
ans =
['***', blanks(10), '***']
ans =
*** ***
['***', blanks(20), '***']
ans =
*** ***
sprintf('Hello, how are you?\n My name is Tamar Shinar.\n')
ans =
Hello, how are you?
My name is Tamar Shinar.
mySentences = sprintf('Hello, how are you?\n My name is Tamar Shinar.\n')
mySentences =
Hello, how are you?
My name is Tamar Shinar.
mySentences = sprintf('Hello, how are you?\n My name is Tamar Shinar %d.\n',10)
mySentences =
Hello, how are you?
My name is Tamar Shinar 10.
myString = ' hello '
myString =
hello
strjust(myString,'right')
ans =
hello
result = strjust(myString,'right');['***', result, '***']
ans =
*** hello***
result = strjust(myString,'left');['***', result, '***']
ans =
***hello ***
result = strjust(myString,'center');['***', result, '***']
ans =
*** hello ***
result = deblank(' hello ');['***', result, '***']
ans =
*** hello***
diary off