Sunteți pe pagina 1din 3

Lab Experiment 1: Using MATLAB for Control Systems

Objective: The objective of this exercise is to Re-call your concept of mathematical programming using MATLAB. Which you have already learnt in C.T.-II (labs).

Exercise # 1:
Answer the following questions in your own words: Q1. What is MATLAB ? Q2. MATLAB Stands for_______? Q3. The MATLAB environment allows the user to: i. Manage variables ii. Import and export data iii. Perform calculations iv. Generate plots v. Develop and manage files for use with matlab. Tick out the right options. Q4. Write down the purpose of: i. Work Space Window iv. Graphic (Figure) Window ii. Command History Window v. M-file editor/debugger window iii. Command Window Q5. How to name a Matlab file? Q6. How to name a Variable? Q7. What happen, if we write a semi-colon at the end of each command? Q8. What are the Special Variables? Q9. Write down the function of the following commands: i. who iii. clear v. clc ii. whos iv. clear name vi. clf Q10. What is a Row Vector? How it can be created? Q11. What is a Column Vector? How it can be created? Q12. How can we address the vector element? Q13. Write down the function of the following commands: i. x=start:end iv. length(x) ii. x=start:increment:end v. y=x iii. linespsce(start,end,nember) vi. dot(x,y) Q14. What is a Matrix Array? How it can be created? Q15. How can we address the Matrix element? Q16. Write down the function of the following commands for a matrix A: i. zeros(n) iv. ones(m,n) vii. size (A) ii. zeros(m,n) v. rand(n) viii. length(A) iii. ones(n) vi. rand(m,n) Q17. Write down the commands for the following purpose: i. Transpose vi. Matrix Elements Multoplication ii. Identity matrix vii. Matrix Inverse iii. Addition and subtraction viii. Matrix Power iv. Scalar Multiplication ix. Scalar Division v. Matrix multiplication x. Determinant

Page 1 of 3

Lab Teacher: Iqbal Azeem

Lab Experiment 1: Using MATLAB for Control Systems

Exercise # 2:
Plotting: For the information on 2-D plotting, type help graph2d
Plotting a point: plot ( variablename, symbol) Example: Complex number z = 1 + 0.5j; plot (z, .) COMMANDS FOR AXES:

PLOTTING CURVES: plot (x,y) generates a linear plot of the values of x (horizontal axis) and y (vertical axis). semilogx (x,y) generate a plot of the values of x and y using a logarithmic scale for x and a linear scale for y semilogy (x,y) generate a plot of the values of x and y using a linear scale for x and a logarithmic scale for y. loglog(x,y) generate a plot of the values of x and y using logarithmic scales for both x and y MULTIPLE CURVES: plot (x, y, w, z) multiple curves can be plotted on the same graph by using multiple arguments in a plot command. The variables x, y, w, and z are vectors. Two curves will be plotted: y vs. x, and z vs. w. legend (string1, string2,) used to distinguish between plots on the same graph MULTIPLE FIGURES: figure (n) used in creation of multiple plot windows. place this command before the plot() command, and the corresponding figure will be labeled as Figure n close closes the figure n window. close all closes all the figure windows. SUBPLOTS: subplot (m, n, p) m by n grid of windows, with p specifying the current plot as the pth window

Page 2 of 3

Lab Teacher: Iqbal Azeem

Lab Experiment 1: Using MATLAB for Control Systems Practice Example: (polynomial function) Plot the polynomial using linear/linear scale, log/linear scale, linear/log scale, & log/log scale: y = 2x 2 + 7x + 9 % Generate the polynomial: x = linspace (0, 10, 100); y = 2*x.^2 + 7*x + 9; % plotting the polynomial: figure (1); subplot (2,2,1), plot (x,y); title ('Polynomial, linear/linear scale'); ylabel ('y'), grid; subplot (2,2,2), semilogx (x,y); title ('Polynomial, log/linear scale'); ylabel ('y'), grid; subplot (2,2,3), semilogy (x,y); title ('Polynomial, linear/log scale'); xlabel('x'), ylabel ('y'), grid; subplot (2,2,4), loglog (x,y); title ('Polynomial, log/log scale'); xlabel('x'), ylabel ('y'), grid;

Page 3 of 3

Lab Teacher: Iqbal Azeem

S-ar putea să vă placă și