## Documents

Description
COMSATS Institute of Information Technology, Electrical Engineering Department, Attock. Numerical Computation Experiment / Lab Task # 01 Objective: The objective of this lab is to familiarize students with the matlab environment. How data is stored in matlab. How scalars, vectors and matrices are generated in matlab. How indexing is done is matlab. How to access the values from vectors and matrices. What are the possible ways for searching the help about any command in matlab. Brief introducti
Categories
Published

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
COMSATS Institute of Information Technology, Electrical Engineering Department, Attock. Numerical Computation Experiment / Lab Task # 01   Objective: The objective of this lab is to familiarize students with the matlab environment. How data is stored in matlab. How scalars, vectors and matrices are generated in matlab. How indexing is done is matlab. How to access the values from vectors and matrices. What are the possible ways for searching the help about any command in matlab. Brief introduction to basic commands for generating vectors, trigonometric functions, arithematic operators, logical operators. At the end comprehensive detail about plotting the data in matlab and the complete customization of plots. Commands to be used:    Help    xlabel    Clc    ylabel    Close all    Hold on    Clear all    Pause    Plot    Sin    Stem    Cos    Subplot    Pascal    Figure    Randn    title    fix    COMSATS Institute of Information Technology, Electrical Engineering Department, Attock. Questions: Instruction (Do write comment infront of every statement) Q.1. Create a symmetric matrix ‘m’ with five rows and five columns. Calculate its transpose and verify that the matrix is symmetric by observing that m=m’.  Q.2. Create a random matrix with 3 rows and 4 columns. The matrix values should be integer b/w (0 —100), than change its any 2 rows values by ‘1.5’. Q.3. Operate with the vectors V1 = [1 2 3 4 5 6 7 8 9 0] V2 = [0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9] V3 = [4 4 4 4 3 3 2 2 2 1] a) Calculate, respectively, the sum of all the elements in vectors V1, V2, and V3 b) How to get the value of the fifth element of each vector? What happens if we execute the command V1(0) and V1(11)? Remember if a vector has N elements, their subscripts are from 1 to N. c) Generate a new vector V4 from V2, which is composed of the first five elements of V2. d) Generate a new vector V5 from V2, which is composed of the last five elements of V2. e) Derive a new vector V6 from V2, with its 6th element omitted. f) Derive a new vector V7 from V2, with its 7th element changed to 1.4. g) Derive a new vector V8 from V2, whose elements are the 1st, 3rd, 5th, 7th, and 9th elements of V2 h) What are the results of 9-V1 V1*5 V1+V2 V1-V3 V1.*V2 V1*V2 V1.^2 V1.^V3 V1^V3 V1 == V3 V1>6 V1>V3 V3-(V1>2) (V1>2) & (V1<6)    COMSATS Institute of Information Technology, Electrical Engineering Department, Attock. (V1>2) | (V1<6) any(V1) all(V1) 2. Compare a script and a function a) Write a script: In the main menu of Matlab, select file -> new -> M-file A new window will pop up. Input the following commands: x = 1:5; y = 6:10; g = x+y; and then save the file as myscript.m under the default path matlab/work b) Write a function: Create a new m file following the procedure of above. Type in the commands: function g = myfunction(x,y) g = x + y; and then save it as myfunction.m i. Compare their usage run the commands one by one: myscript x y g z = myscript (error?) ii. Run command clear all to remove all variables from memory iii. Run the commands one by one: x = 1:5; y = 6:10; myfunction (error?) z = myfunction(x,y) g (error?) a = 1:10; b = 2:11; myfunction(a,b)

Jul 23, 2017

#### kse-131005051021-phpapp01

Jul 23, 2017
Search
Similar documents

View more...
Tags

Related Search