You are on page 1of 2

MATLAB TRAINING INTRODUCTORY MATERIAL MATLAB Problem 1 Part (a) Create an m-file script which does the following:

Read in data from a file (use csvread function, read in data.csv) ispla! the data to the Command "indow (read about semicolons) Plot the arra!s of data in an #-! graph (use plot function) Part (b) $it an %th order pol!nomial to the data in part (a) and output the coefficients of the pol!nomial to the Command "indow (use polyfit and polyval functions) Plot the pol!nomial in a new figure (use plot function) Part (c) Convolve the original data five times with itself (use conv function) Plot the result of the convolutions in a new figure (use plot function) Problem & Part (a) Create and save a new m-file called m!function.m with a function header which accepts two values (# and !) 'et # be the number of randoml! valued elements in a one dimensional matri# called p (use rand function) 'et ! be the number of bins in a histogram plot of # (use hist function) Part (b) Create a script which re(uests from the user the values of # and ! from Part (a) and then calls m!fuction.m with those values

Problem ) Part (a) Create a *+, using -./'.01s *+, 2 program (t!pe 3guide4 into the Command "indow) /he *+, should have two te#t windows for inputs (# and !) and a 3*o4 button which e#ecutes m!function.m from part (a) Part (b) ,nclude handlers which chec5 the values entered into the *+, to ensure that the! are numerical and that # is greater than !. ,f # is less than or e(ual !, displa! the te#t 36 should be greater than 74 to the Command "indow. SIMULINK Problem 8 Part (a) Create a new 9,-+',:; model. Place two Constant bloc5s (# and !). Create the following mathematical function with 1) bloc5s, &) embedded function bloc5, )) 9-$unction bloc5: 2y z = 25 x 2 + 60 x + 100 + 14 x 2 Part (b) < (+se one of the three implementations from part (a) to complete part (b)) Replace the Constant bloc5s with the abilit! to read data from the data.csv file used in Problem 1 and e#ecute one line of data for each time-step in a simulation. 9ave 3=4 to the -./'.0 0ase wor5space. Stateflow Read through the 9tateflow documentation and 5now how to open a 9tateflow chart.

You might also like