To get started, select "MATLAB Help" from the Help menu. >> a = 4 a = 4 >> a a = 5 >> avector [1 2 3] ??? avector [1 2 3] | Error: Missing operator, comma, or semicolon. >> avector = [1 2 3] avector = 1 2 3 >> bvector =[4 5 6] bvector = 4 5 6 >> avector*bvector ??? Error using ==> * Inner matrix dimensions must agree. >> bvector =bvector' bvector = 4 5 6 >> avector*bvector ans = 32 >> avector.*avector ans = 1 4 9 >> amatrix=[1 2;3 4] amatrix = 1 2 3 4 >> size(amatrix) ans = 2 2 >> amatrix(1,:) ans = 1 2 >> amatrix(2,:) ans = 3 4 >> amatrix(:,1) ans = 1 3 >> aamatrix[1 2 3; 4 5 6; 7 8 9] ??? aamatrix[1 2 3; 4 5 6; 7 8 9] | Error: Missing operator, comma, or semicolon. >> aamatrix =[1 2 3; 4 5 6; 7 8 9] aamatrix = 1 2 3 4 5 6 7 8 9 >> aamatrix(1:2,:) ans = 1 2 3 4 5 6 >> aamatrix(1:2,1:2) ans = 1 2 4 5 >> aamatrix(1:2,2:3) ans = 2 3 5 6 >> aaamatrix = [aamatrix(1,:); aamatrix(3,:)] aaamatrix = 1 2 3 7 8 9 >> To get started, select "MATLAB Help" from the Help menu. a = 4 a = 4 a a = 5 avector [1 2 3] ??? avector [1 2 3] | Error: Missing operator, comma, or semicolon. avector = [1 2 3] avector = 1 2 3 bvector =[4 5 6] bvector = 4 5 6 avector*bvector ??? Error using ==> * Inner matrix dimensions must agree. bvector =bvector' bvector = 4 5 6 avector*bvector ans = 32 avector.*avector ans = 1 4 9 amatrix=[1 2;3 4] amatrix = 1 2 3 4 size(amatrix) ans = 2 2 amatrix(1,:) ans = 1 2 amatrix(2,:) ans = 3 4 amatrix(:,1) ans = 1 3 aamatrix[1 2 3; 4 5 6; 7 8 9] ??? aamatrix[1 2 3; 4 5 6; 7 8 9] | Error: Missing operator, comma, or semicolon. aamatrix =[1 2 3; 4 5 6; 7 8 9] aamatrix = 1 2 3 4 5 6 7 8 9 aamatrix(1:2,:) ans = 1 2 3 4 5 6 aamatrix(1:2,1:2) ans = 1 2 4 5 aamatrix(1:2,2:3) ans = 2 3 5 6 aaamatrix = [aamatrix(1,:); aamatrix(3,:)] aaamatrix = 1 2 3 7 8 9 ??? To get started, select "MATLAB Help" from the Help menu. | Error: Missing operator, comma, or semicolon. >> newmat=zeros(1,3) newmat = 0 0 0 >> newmat newmat = 21 23 125 >> newmat; >> heightfunction(4) ??? Undefined function or variable 'heightfunction'. >> heightfunction(4) ??? Undefined function or variable 'heightfunction'. >> heightfunction(4) ans = 384.9444 >> heightfunction(4) ans = 384.9444 >> heightfucntion(4) ??? Undefined function or variable 'heightfucntion'. >> heightfunction(4) ans = 384.9444 >> hreturn ??? Undefined function or variable 'hreturn'. >> [hreturn htreturn] = heightfunction(4) hreturn = 384.9444 htreturn = 192.4722 >> ysquared(1,1) ans = 4 >> help ode45 ODE45 Solve non-stiff differential equations, medium order method. [T,Y] = ODE45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates the system of differential equations y' = f(t,y) from time T0 to TFINAL with initial conditions Y0. Function ODEFUN(T,Y) must return a column vector corresponding to f(t,y). Each row in the solution array Y corresponds to a time returned in the column vector T. To obtain solutions at specific times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN = [T0 T1 ... TFINAL]. [T,Y] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default integration properties replaced by values in OPTIONS, an argument created with the ODESET function. See ODESET for details. Commonly used options are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector of absolute error tolerances 'AbsTol' (all components 1e-6 by default). [T,Y] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS,P1,P2...) passes the additional parameters P1,P2,... to the ODE function as ODEFUN(T,Y,P1,P2...), and to all functions specified in OPTIONS. Use OPTIONS = [] as a place holder if no options are set. ODE45 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is nonsingular. Use ODESET to set the 'Mass' property to a function MASS if MASS(T,Y) returns the value of the mass matrix. If the mass matrix is constant, the matrix can be used as the value of the 'Mass' option. If the mass matrix does not depend on the state variable Y and the function MASS is to be called with one input argument T, set 'MStateDependence' to 'none'. ODE15S and ODE23T can solve problems with singular mass matrices. [T,Y,TE,YE,IE] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events' property in OPTIONS set to a function EVENTS, solves as above while also finding where functions of (T,Y), called event functions, are zero. For each function you specify whether the integration is to terminate at a zero and whether the direction of the zero crossing matters. These are the three vectors returned by EVENTS: [VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function: VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration is to terminate at a zero of this event function and 0 otherwise. DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only zeros where the event function is increasing, and -1 if only zeros where the event function is decreasing. Output TE is a column vector of times at which events occur. Rows of YE are the corresponding solutions, and indices in vector IE specify which event occurred. Example [t,y]=ode45(@vdp1,[0 20],[2 0]); plot(t,y(:,1)); solves the system y' = vdp1(t,y), using the default relative error tolerance 1e-3 and the default absolute tolerance of 1e-6 for each component, and plots the first component of the solution. See also other ODE solvers: ODE23, ODE113, ODE15S, ODE23S, ODE23T, ODE23TB options handling: ODESET, ODEGET output functions: ODEPLOT, ODEPHAS2, ODEPHAS3, ODEPRINT ODE examples: RIGIDODE, BALLODE, ORBITODE NOTE: The interpretation of the first input argument of the ODE solvers and some properties available through ODESET have changed in this version of MATLAB. Although we still support the v5 syntax, any new functionality is available only with the new syntax. To see the v5 help, type in the command line more on, type ode45, more off >> [t,y]=ode45('ysquared',[0 50], 0.5); Warning: Failure at t=8.008423e-001. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.845164e-015) at time t. > In C:\matlabR12\toolbox\matlab\funfun\ode45.m at line 319 >> [t,y]=ode45('ysquared',[0 50], 0.5); >> size (t) ans = 93 1 >> size (y) ans = 93 1 >> plot(t,y) >> ysquared(1,[2 3]) ans = -3.5000 -2.7000 >> [t,y]=ode45('ysquared',[0 50], [4 7]); >> size (t) ans = 117 1 >> plot(t,y) >> plot(t,y(:,1)) >> plot(t,y(:,2)) >> plot(t,y) plot(t,y(:,2)) >> plot(t,y) >> plot(t,y(:,1)) >> plot(t,y(:,2)) >> hold Current plot held >> plot(t,y(:,1)) >> hold Current plot released >> plot(t,y) >> 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, length(Y) disconnected points are plotted. 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: y yellow . point - solid m magenta o circle : dotted c cyan x x-mark -. dashdot r red + plus -- dashed g green * star b blue s square w white d diamond k black 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. The default ColorOrder is listed in the table above for color systems where the default is yellow for one line, and for multiple lines, to cycle through the first six colors in the table. For monochrome systems, PLOT cycles over the axes LineStyleOrder property. PLOT returns a column vector of handles to LINE objects, one handle per line. The X,Y pairs, or X,Y,S triples, can be followed by parameter/value pairs to specify additional properties of the lines. See also SEMILOGX, SEMILOGY, LOGLOG, GRID, CLF, CLC, TITLE, XLABEL, YLABEL, AXIS, AXES, HOLD, COLORDEF, LEGEND, SUBPLOT, and STEM. Overloaded methods help iddata/plot.m help idmodel/plot.m help dtree/plot.m help ntree/plot.m help edwttree/plot.m help rwvtree/plot.m help wvtree/plot.m >> plot(t,y(:,1),'c+:') >> hold Current plot held >> plot(t,y(:,2),'cx:') >> hold Current plot released >> plot(t,y(:,1),'c+:') >> [tt,yy]=ode45('ysquared', [0 15], [4 5],[],.1) ??? Error using ==> ysquared Too many input arguments. Error in ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments.m On line 97 ==> f0 = feval(ode,t0,y0,args{:}); Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >> [tt,yy]=ode45('ysquared', [0 15], [4 5],options=[],.1) ??? [tt,yy]=ode45('ysquared', [0 15], [4 5],options=[],.1) | Error: MATLAB assignment cannot be nested. >> [tt,yy]=ode45('ysquared', [0 15], [4 5],[ ],.1) ??? Error using ==> ysquared Too many input arguments. Error in ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments.m On line 97 ==> f0 = feval(ode,t0,y0,args{:}); Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >> [tt,yy]=ode45('ysquared', [0 15], [4 5],OPTIONS=[],.1) ??? [tt,yy]=ode45('ysquared', [0 15], [4 5],OPTIONS=[],.1) | Error: MATLAB assignment cannot be nested. >> [tt,yy]=ode45('ysquared', [0 15], [4 5],[],.1) ??? Error using ==> ysquared Too many input arguments. Error in ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments.m On line 97 ==> f0 = feval(ode,t0,y0,args{:}); Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >> [tt,yy]=ode45('ysquared', [0 15], [4 5],.1) ??? Error using ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments Correct syntax is ode45(YSQUARED,tspan,y0,options). Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >> [tt,yy]=ode45('ysquared', [0 15], [4 5],[],0.1) ??? Error using ==> ysquared Too many input arguments. Error in ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments.m On line 97 ==> f0 = feval(ode,t0,y0,args{:}); Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >> p=0 p = 0 >> [tt,yy]=ode45('ysquared', [0 15], [4 5],[],0.1) ??? Error using ==> ysquared Too many input arguments. Error in ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments.m On line 97 ==> f0 = feval(ode,t0,y0,args{:}); Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >> ysquared(2, [4 5], 0.5) ans = -6.5000 -4.7000 >> [tt,yy]=ode45('ysquared', [0 15], [4 5],[],0.1) ??? Error using ==> ysquared Too many input arguments. Error in ==> C:\matlabR12\toolbox\matlab\funfun\private\odearguments.m On line 97 ==> f0 = feval(ode,t0,y0,args{:}); Error in ==> C:\matlabR12\toolbox\matlab\funfun\ode45.m On line 146 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ... >>