### Introduction

LOCEN uses MATLAB (and R) to perform the data analysis of its experiments. LOCEN also uses MATLAB (and also Python) as programming language to prototype some of its models. The reason of this is that it is very easy and fast to program with MATLAB (and Python). On the other side, MATLAB is a interpreted language (similarly Python), so it is very slow at execution time. For this reason we use C++ to have fast programs. MATLAB can be made faster by parallelising its code and executing programs with multi-processor computer (now commonly used). However, this is advantageous only for heavy matrix calculus, but not with LOCEN type of simulations that have many loops with single variable or small vector operations, executed for millions and millions of times. The reason why our simulations have these features is that they usually simulate the interaction cycles between the organism/robot and its environment (embodied systems) and also simulate the learning processes of these systems happening during these simulations.

### lEARNING TO PROGRAM IN MATLAB

A tutorial for Matlab from an authoritative website (MathWorks) can be found here:

http://it.mathworks.com/support/learn-with-matlab-tutorials.html

A gentle tutorial for psychologists can be found in the following link. Here is how the author of the tutorial describes it: ''Matlab is a wonderful program for data analysis if you know how to use it, but it can be a bit intimidating because everything tends to be described for mathematicians. So over the last year I've compiled a basic guide to tell you only the bits of Matlab which you need to know for running and analysing psychology experiments. It is in the form of a tutorial, and assumes that you know nothing about Matlab but have access to it and can work through the examples and exercises.'' Here is the link:

http://www.antoniahamilton.com/matlab.html

### Downloading MATLAB

To use Matlab, you need a licence. However, you can download Matlab and use it for trial, e.g. as student, from here:

http://it.mathworks.com/products/matlab/

### Octave, an open sources clone of MATLAB

A very good alternative to MATLAB is Octave, which has the great advantage of being free of costs, a clone of MATLAB, meaning that it uses the same programming language as MATLAB. There are only few exception to this interoperability, related to some graphical and other functions that can be easily avoided. Octave can be used under Linux and Windows. You can download Octave from here:

https://www.gnu.org/software/octave/

### Basic commands in MATLAB

Here we present a program that summarises the main commands in Matlab: copy-paste it into a Matlab script and follow the instructions to use it.

%%% MATLAB EXAMPLE INSTRUCTIONS %%% %%% by Gianluca Baldassarre %%% %%% Institute of Cognitive Sciences %%% %%% National Research Council of Italy %%% %%% Rome 05/01/2009 --> 10/12/15 %%%%%% INTRODUCTION %%% %%% This Matlab .m file contains a list of examples of Matlab instructions %%% that exemplify the core Matlab functionalities. %%% The examples have been written with two goals in mind: %%% (1) Furnish a crash course for people willing to learn Matlab %%% (2) Furnish a list of the core Matlab functionalities %%% to people that, like me, often forgot the name of such functions %%% Instructions: how to use this file. %%% Before starting, I suggest you to ask who knows Matlab to show you %%% how to create, use,and modify Matlab scripts as the one of this file %%% (this will take ten minutes). %%% Then, to see the effects of the examples reported below, %%% simply uncomment those relevant for you %%% (to do this, hightlight them, rightclick, select 'uncomment') and then %%% run the script of this file, view the results in the command window %%% and workspace, modify the examples as you like to see the effects, %%% run again, etc. %%% I suggest you to uncomment and execute a block per time %%% othewise it is difficult to read the results in the command window %%% and workspace. %%% Have fun!

%%% GENERAL %%% %%%%%%%%%%%%%%%% GENERAL UTILITIES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%The character % is used to comment lines %%The character ; is used to avoid printing output on command window %%The character ... is used to cut a line of instructions into two lines %%To visualise content of varibles, write their name in command window %%You can use Matlab as a calculator by writing operations directly in the %%commmand window and pressing enter. The variables created are stored %%automatically in the work space (the 'working memory' of the application), %%so you can use them. These two possibilities allow you %%to easily test the functioning of MATLAB operations by writing them in %%the command window and inspecting the results. %%You can highlight any piece of code in a script file and execute it in %%the consol by pressing F9 %%Writing and executing 'help Matlab_element' in the consol returns info on %%any element of Matlab called 'Matlab_element'. E.g., try with 'help min' %%Do not comment the following three instructions so that each time you %%run this script the command window and the workspace will be cleaned: clear %Delete variables from work memory (see also help on 'clear') clc %Delete previous outputs and commands from command window %close all %Closes opened windows, e.g. of previous figures %clf %Clears windows opened by previous simulations without closing %them, so you can doc and update them at each run START = 1 %Run the program: if MATLAB prints START=1 in your consol, it means this program wors OK and you can start to play with it.

%% %%%%%%%%%%%%%%%%%% BASICS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% DATA, FILES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%SAVING DATA TO FILES AND LOADING DATA FROM FILES %%Save data into file % n=input('Inserisci numero valori: ') % x=linspace(0,10,n); % y=x.^2; % save dati.dat y -ascii %Also try: save dati.dat x y -ascii % load dati.dat; % matr = dati %%Load data % load file.dat; % mMatr = file %%Predefined nemerical values of special parameters: % ans % last operation executed without assignement to variable % i %imaginary unit (you can use imaginary numbers, e.g. ''a=3+2i'') % j %imaginary unit (you can use imaginary numbers, e.g. ''a=3+2i'') % pi % Greek pi = 3.14159265... % eps % machine precision % realmax % max machine positive number % realmin % min machine positive number % Inf % a number bigger than realmax % NaN % not a number, e.g. = 0/0

%%%%%%%%%%%% CREATION OF SCALAR, VECTOR, MATRIX %%%%%%%%%%%%%%%%%%%%%%%%%% %%Creation of a scalar (Matlab considers it a matrix 1x1, see workspace) % sScal = 2 %%Creation of vector (Matlab considers it a matrix) % vRowVect = [1 2] % vColuVect = [1 ; 2] %%Creation of matrix: % mMatr1 = [1 2; 3 4; 5 6] % mMatr2 = [7 8 % 9 10]

%%%%%%%%%%%% INITIALISATION WITH EQUIDISTANT VALUES %%%%%%%%%%%%%%%%%%%%%% % vVect = 1:10 % vVect = 0:0.1:1 % vVect = linspace(0, 1, 7) %7 equidistant elements from 0 to 1 % vVect = logspace(1, 10, 20) %20 equidistante elements from 0 to 1

%%%%%%%%%%%% INITIALISATION OF MATRIX WITH PARTICULAR VALUES (see help) %% % mMatrZeros = zeros(2, 3) % Initialisation with 0 % mMatrOnes = ones(2, 3) % Initialisation with 1 % mMatrEye = eye(2, 3) % Initialisation of identity matrix % mMatrDiag = diag(7, 5) %See help diag

%%%%%%% READING AND WRITING ELEMENTS OF A VECTOR OR MATRIX %%%%%%%%%%%%%%% % vVect = [1 2] % vVect(1) = vVect(2) % mMatr = [1 2; 3 4]; % mMatr(1, 2)

%%%%%%%%%%%%%%% THE POWERFUL NOTATION : FOR INDEXES RANGES; end %%%%%%%%%% %mMatr = [1 2 3; 4 5 6; 7 8 9]; %mMatr(:,1) %mMatr(1,:) % mMatr(1,1:2) % mMatr(1:2,2:3) % mMatr(1:2, 2:end) %Note the effect of 'end', useful with variable sizes %%Note that : can also be used for assignement % mMatr(1,:) = [7 7 7] % 7:2:11

%% %%%%%%%%%%%%%% FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%% BASIC MATH AND LINEAR ALGEBRA OPERATORS %%%%%%%%%%%%%%%%%%%%%% %%The following lines are just to know the operations you can use, so %%you cannot execute them: try to use them by typing operations directly %%in the command window as illustrated above. %%Matrix by scalar operators: %%+ - * / .^ %E.g.: X-1, X.^2 (as X^2=X*X) %%Scalar by matrix operators: %%+ - .* ./ %E.g.: 1+X, X./2 (as 1/X= 1 * inv(X)... to be checked) %%Matrix by matrix element-by-element operators: %%+ - .* ./ .^ %%Matrix by matrix, linear algebra operators: %%* % Dot product %%/ % Y/X=Y * inv(X) %%^ % X^2 = X * X %%' % Transpose %%EXP(x) %e to the x %%Functions (mathematics and trigonometry)(again you cannot execute them): %%exp log sqrt abs sign ...see below for help on whole list of func. %%sin cos asin acos tan atan atan2 ...see below for help on list of func.

%%%%%%%%%%%%%%%% HELP ON FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%In general, 'help function_name' gives info on function called %%'function_name' % help elfun % List of all functions % lookfor logarithm % Functions related to 'logarithm'

%%%%%%%%%%%%%%% GENERIC OPERATOR BETWEEN TWO MATRICES %%%%%%%%%%% %mMatr = zeros(5); %vVect = (1:5)'; %bsxfun expands based on larger index %mResu = bsxfun(@plus, mMatr, vVect)

%%%%%%%%%%%%%%% LENGTH OF VECTOR, SIZE OF MATRIX %%%%%%%%%%%%%%%%%%%%%%%%% %%Length of vectors, size of matrix (and scalars and vectors) % scal = 1; % vect = [7 9]; % length(vect) % matr = [1 2; 3 4; 5 6]; % size(scal) % size(vect) % size(matr) % sNumbRows = size(matr, 1) % sNumbColu = size(matr, 2)

%%%%%%%%%%%%%%%% MIN AND MAX FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % vVect = [1 2 4 3]; % mMatr = [1 5 3; 4 2 6]; % sMini = min(vVect) % sMaxi = max(vVect) % vMini = min(mMatr) % vMaxi = max(mMatr) %% Coputing max and index in a matrix % mMatr = [1 5 3; 4 2 6]; % [sMaxiCols,vIndeRows] = max(mMatr,[],1) %Max along first dimension % [sMaxiRows,vIndeCols] = max(mMatr,[],2) %Max along second dimension % [sMax, sMaxIndeRows] = max(sMaxiRows) % [sMax, sMaxIndeCols] = max(sMaxiCols)

%%%%%%%%%%%%%%%% STATISTICAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % mMatr = [1 2 3; 3 4 5]; % vMean = mean(mMatr) %Mean by column % vMean = mean(mMatr,1) %Mean by column % vMean = mean(mMatr,2) %Mean by row

%%%%%%%%%%%%%%%% NORMALISATION OF ORDER P %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %vVect = ones(100,1) %P = 2; %sNorm = norm(vVect,P) %sum(abs(V).^P)^(1/P) See help norm for matrix norm %mMatr = [1 1; 1 2]; %normr(mMatr)%Normalise rows of matrix to length of 1 %normc(mMatr)%Normalise columns of matrix to length of 1

%% %%%%%%%%% RANDOM FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% GENERATING MATRIX WITH RANDOM CONTINUOUS VALUES %%%%%%%%%%%%% % sRand = rand() % matrRand = rand(2, 3) %Try to execute more times! % S = rand('state') % is a 35-element vector containing the current state %%of the uniform random number generator % rand('state',S) %resets the state to S. % rand('state',0) %resets the generator to its initial state. % rand('state',J)% for integer J, resets the generator to its J-th state. % rand('state',sum(100*clock))% resets it to a different state each time. %%Example %rand('state',7); %Set the reandom seed to 7 %rand(2) %rand('state',7); %Set the random seed to 7 %rand(2) %Same random as before

%%%%%%%%%%%%% GENERATING MATRIX WITH RANDOM INTEGER VALUES %%%%%%%%%%%%%%%% %sMin = 8 %sMax = 10 %sN = 3 %sM = 4 %mMatr = [1 2; 3 4; 5 6] %mRand = randi(sMax, sN) %Returns an sN-by-sN matrix with random integer %values drawn from discrete uniform 1:sMax % mRand = randi(sMax, sN, sM) %Returns an sN-by-sM matrix % mRand = randi(sMax,[sN,sM]) %Returns an sN-by-sM matrix % mRand = randi(sMax,size(mMatr)) %Returns array with same size as A % mRand = randi([sMin,sMax], sN, sM) %Returns an sM-by-sN matrix

%%%%%%%%%%%%% RANDOM SHAFFLE OF MATRIX ROWS OR COLUMNS %%%%%%%%%%%%%%%%%%% %mMatr = [1 4; 2 5; 3 6] %mMatr = mMatr(:,[2 1]) %Changes colum in a given way %vRandPerm = randperm(4) %mMatr = mMatr(:,randperm(size(mMatr,2))) %Shaffles columns randomly

%%%%%%%%%%%% RANDOM GAUSSIAN (NORMAL) VALUES %%%%%%%%%%%%%%%%%%%%%%%%%%%%% % mMatrStanNormRand = randn(2,3) %Num rows, num columns % mMatrNormRand = normrnd(1, 1, 2, 3) %Mu, Sigma, nRows, nColu % mMu = [1, 2; 3, 4]; % mSigma = [.1, .1; 10, 10]; % mMatrNormRand = normrnd(mMu, mSigma, 2, 2)

%% %%%% MULTIVARIATE NORMAL GAUSSIAN PROBABILITY DENSITY FUNCTCION %%%%%%% %mData = [0 1; 2 3]; sMu = 0; sSigm = 1; %mProb = normpdf(mData, sMu, sSigm)%Probability density of matrix elements %mProb = normpdf(mData, sMu, sSigm)/normpdf(0,sMu,sSigm)%With max = 1 %mInpu = [0 0; 1 1; 2 2]; %mProb = mvnpdf(mMatr)/mvnpdf([0 0])%Probability density of the multivariate normal distribution %%with zero mean and identity covariance matrix, %%evaluated at each row of mMatr. %Example from help %mu = [1 -1]; Sigma = [.9 .4; .4 .3]; %[X1,X2] = meshgrid(linspace(-1,3,25)', linspace(-3,1,25)'); %X = [X1(:) X2(:)]; %p = mvnpdf(X, mu, Sigma); %surf(X1,X2,reshape(p,25,25));

%% %%%%%%%%% OPERATIONS ON BLOCKS OF A MATRIX %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% ELIMINATION OF BLOCKS OF ELEMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%% %%Elimination of elements of vectors, or whole columns/rows of matrix % vect = 1:10 % vect(2:4) = [] %Elmination of vector elements % matr = [1 2 3; 4 5 6; 7 8 9] % matr(:,1) = [] %Elimination of matrix rows/columns

%%%%%% TRANSFORMATION MATRIX TO VECTOR OR MATRIX TO MATRIX %%%%%%%%%%%%%%% %%Reshaping matrices and vectors (works from top to bottom, left to right)) % matr = [1 5 9; 2 6 10; 3 7 11; 4 8 12]; % matrResh = reshape(matr, 2, 6) %%From matrix to vector % matr = [1 5 9; 2 6 10; 3 7 11; 4 8 12]; % vect = matr(:) %%Note important use of (:), which gives always *column* vector: % vect1 = [1 2 3]; % vect2 = [1 2 3]; % vect3 = vect1' % vect4 = vect3(:) % vect5 = vect2(:) %%Part of matrix to vector % vVect = [0 0] % mMatr = [1 2; 3 4] % vVect = mMatr(:, 1) %%Matrix formed by copying (tiling, repeating) a small matrix or vector %mA = [1 2; 3 4] %sM = 2 %sN = 3 %mB = repmat(mA,sM,sN) %mB has dimentions: [size(mA,1)*sM, size(mA,2)*sN]. %mB = repmat(mA,sN) %Creates an sN-by-sN tiling. %%Concatenation of vectors and matrixes %mMat1 = [1 2; 3 4] %mMat2 = [5 6; 7 8] %mMat3 = [mMat1 mMat2]%Concatenates horizontally %mMat3 = [mMat1; mMat2]%Concatenates vertically %repmat(mMatr, 2, 3) %cat(1,mMat1,mMat2)%Concatenates along dimention 1 %cat(2,mMat1,mMat2)%Concatenates along dimention 2 %vertcat(mMat1,mMat2)%Concatenates along dimention 1 %horzcat(mMat1,mMat2)%Concatenates along dimention 1 %% Getting only triangular part of matrix, and setting the rest to 0 %mMatr = rand(4); %mMatrLowe = tril(mMatr) %mMatrUppe = triu(mMatr)

%% %%%%%%%%% MATLAB AS PROGRAMMING LANGUAGE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%General suggestion % (1) avoid using 'for': instead use linear algebra computations, see above % (2) avoid using 'if': instead use powerful logic operators, see below %%Programming commands % numb = zeros(1, 10); % trueFals = zeros(1, 10); % scal = 0; % for coun = 1:10 % scal = scal + 1; % if(scal < 3) % trueFals(coun)=0; % elseif(6 < scal) % trueFals(coun)=2; % else % trueFals(coun)=1; % end % end % trueFals % coun %%Programming commands % coun = 1 % while coun < 10 % coun = coun + 1; % end % coun %%Logic operators % & | ~ xor % == ~= < > <= >=

%% %%%%%%%% LOGIC OPERATORS WITH VECTORS AND MATRIXES %%%%%%%%%%%%%%%%%%%%% %%Logic operators are very powerful if used with vectors/matrix: % matr = rand(3,3); % matr = matr<0.5

%% %%%%%%% SORTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % vVect = rand(10,1); % mMatr = rand(10); % sort(vVect) %Sorts in ascending order % sort(mMatr) %Sorts in acending order each column % mMatr = rand(10); % sort(mMatr,1,'ascend') %Sorts along dimention 1 in 'ascend'/'descend' order

%% %%%%%% CUMULATIVE SUM AND PRODUCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %vVect = rand(10,1); %cumsum(vVect) %cumprod(vVect)

%% %%%%%%% PROBABILITY CREATION AND RANDOM EXTRACTION %%%%%%%%%%%%%%%%%%%% %vVect = rand(10,1)*10; %Ten numbers %vP = cumsum(vVect)/sum(vVect); %Cumulated sum of the ten numbers, normalised %sIndeWinn = sum(vP < rand(1))+1

%% %%%%%%%% LAST TO BE < K %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %vVect = rand(10,1); %vVect = sort(vVect); %k = 0.45; %vLast = sum(vVect < k)

%% %%%%%%%%%%%%%%%% PRINT IN CONSOL, SUSPEND (STOP) PROGRAM BY KEYBOARD (HAND) %%% %fprintf('Program paused. Press enter to continue.\n'); %pause;

%% %%%%%%%%%%%%%%%% GRAPHICS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%GRAPHS: PLOT, SUBPLOT, HOLD ON, HOLD OFF, AXIS, YLABEL, XLABEL, TITLE % n = 21; % x = linspace(0,2*pi,n); % y = cos(x); % subplot(2,2,1) % plot(x,y) % subplot(2,2,2) % plot (x,y,'-') % hold on % plot (x,y,'o') % subplot(2,2,3) % plot (x,y,'-') % hold off % plot (x,y,'o') % subplot(2,2,4) % plot(x,y) % axis([-1 8 -2 2]) %axis([xmin xmax ymin ymax]) % title('Grafico') % ylabel('y') % xlabel('x') %%A LINE % x = rand(10, 1); % y = rand(10, 1); % plot(x,y); %%SEGMENTS % figure(1); % hold on; % plot([0 1], [0 1]); %[x1 x2],[y1 y2] % plot([1 0], [1 2]); % hold off; %%KEY GRAPHICAL ELEMENTS %plot([0 .8 2], [0 1.2 2],'r*-'); %title('Segment'); %ylabel('Name on y-axis'); %xlabel('Name on x-axis'); %xLim([0 3]);%Range of x axis %yLim([0 3]);%Range of y axis %%axis([-1 5 -2 4]) %axis([xmin xmax ymin ymax])%Instead of the last two %%SCATTER GRAPH %vX = rand(10,1); %vY = rand(10,1); %scatter(vX, vY); %% IMAGE, IMAGESC %mMatr = repmat((1:10),10,1)+repmat((1:10)',1,10); %figure(1); %image(mMatr); %Displays 2D mMatr as an image, where each element is the color %%TODO, see 'help image' %mMatr can be of dimension MxNx3 %figure(2) %imagesc(mMatr); %%Surface and contour plots (then press 3D button and move with mouse) % n=11; m=11; % x = linspace(0,1,n); % y = linspace(0,1,m); % [X, Y] = meshgrid(x,y); % Z=X.*(1-X).*Y.*(1-Y); % subplot(2,2,1) % surf(X,Y,Z); % subplot(2,2,2) % surface(Z); % subplot(2,2,3) % contour(X,Y,Z); % subplot(2,2,4) % hist(Z(:,(n/2)), 4) %See help hist %%Fundamental trick to modify all graphic elements via script. % Produce a figure. Click on last button 'Show plot tools'. Click on button % 'Inspector' (or 'More properties') either after % having cliked on the graph or the graph axes. % The Inspector will show you all the properties of the object 'graph' or % 'axes'; in this way you can: % (1) know all propeties of graphs by changing them to see their effect; % (2) know the names of such properties so that you can set them within the % scripts: to do this you have to get the handle of the figure or axes. % %%Case 1/2 when figure is created from scratch: % hFigu = figure(); %Creates a window for a graph, gets its handle % set(hFigu,'Name','Figure title'); %Assigns name to window % set(hFigu, 'Position', [300, 300, 500, 500]) %Sets position/size (pixls.) % hAxes = axes(); %Creates axes, gets the axes's handle % set(hAxes, 'Position', [0.1, 0.1, 0.7, 0.7]) %Sets position7size (relat.) % axis([0, 10, 0, 12]) %Sets the scale of axes % %hAxis = axis; %Is this possible? % %%Case 2/2 when figure is first created from scratch then modified: %%Use 'gca' to get handle of current axes %%Use 'gcf' to get handle of current figure window % plot((1:10)+rand(1,10)) % set(gcf,'Name','Trend'); %Assigns name to window % set(gcf, 'Position', [300, 300, 500, 500]) %Sets position & size (pixels) % set(gca, 'Position', [0.1, 0.1, 0.8, 0.8]) %Sets position7size (rel.wind) % set(gca, 'Box', 'on') % set(gca, 'TickLength', [0 , 0]) % axis([0, 10, 0, 12]) %Sets the min-x, max-x, min-y, max-y of axes % axis off; %Does not show axes alltogether

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% 2D Gaussin based function %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %peaks is a MATLAB function to show how MESH, SURF, PCOLOR, CONTOUR work. % [X,Y,Z] = peaks(30); % %surf(X,Y,Z); % %contour(X,Y,Z); % surfc(X,Y,Z); % %pcolor(X,Y,Z);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%Graphical study of functions%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %%Use this for periodic functions % sStep = pi/18; % sNumbPeri=2; % sDuraSimu=sNumbPeri*2*pi; % vX = 0:sStep:sDuraSimu; % %%Put your functions here%% % vY1 = cos(vX); % vY2 = sin(vX); % %%Graphical settings % sMinY=-1; % sMaxY=1; % sMinX=0; % sMaxX=sDuraSimu; % %%Use this for discrete functions % sN = 100; % vX = 0:1:sN; % %%Put your functions here%% % vY1 = vX; % vY2 = vX/2; % %%Graphical settings % sMinY=0; % sMaxY=sN; % sMinX=0; % sMaxX=sN; %%Use this for continuous functions %sSimuDura = 100; %Duration of simulation, e.g. in seconds %sStep=1; %0.1; %vX = 0:sStep:sSimuDura; %%Put your functions here%% %vY1 = exp(-vX/1); %vY2 = vX .^ (.1); %%Graphical settings %sMinY=0; %sMaxY=1; %sMinX=0; %sMaxX=sSimuDura;

%%%%%%Graphics%%%%%% %subplot(2,1,1) %plot(vX,vY1) %axis([sMinX sMaxX sMinY sMaxY]) %hold on %plot (vX,vY1,'+') %subplot(2,1,2) %plot(vX,vY2) %hold on %plot (vX,vY2,'o') %axis([sMinX sMaxX sMinY sMaxY]) %title('Grafico') %ylabel('y') %xlabel('x') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% End study of functions %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%