100% Guaranteed Results


MA202 – IIIT Vadodara Solved
$ 29.99
Category:

Description

5/5 – (1 vote)

MA202 Numerical Techniques
LAB#1 Introduction to MATLAB
MATLAB is a software package for high-performance numerical computation and visualization. It provides an interactive environment with hundreds of built-in functions for technical computation, graphics, and animation. Best of all, it also provides easy extensibility with its own high-level programming language. The name MATLAB stands for MATrix LABoratory.
MATLAB’s built-in functions provide excellent tools for linear algebra computations, data analysis, signal processing, optimization, numerical solution of ordinary differential equations, quadrature, and many other types of scientific computations. Most of these functions use stateof-the-art algorithms. There are numerous functions for 2-D and 3-D graphics, as well as for animation. Also,for those who cannot do without their Fortran or C codes, MATLAB even provides an external interface to run those programs from within MATLAB.
The user, however, is not limited to the built-in functions as he can write his own functions in the MATLAB language. Once written, these functions behave just like the built-in functions. MATLAB’s language is very easy to learn and to use. There are also several optional ”toolboxes” available from the developers of MATLAB. These toolboxes are collections of functions written for special applications such as symbolic computation, image processing, statistics, control system design, and neural networks. The list of toolboxes keeps growing with time. There are now more than 50 such toolboxes. The command window is the main window in which you communicate with the MATLAB interpreter. The basic building block o f MATLAB is the matrix. The fundamental data type is the array. Vectors, scalars, real matrices, and complex matrices are all automatically handled as special cases of the basic data type.
Typing help topic in MATLAB with the appropriate topic name provides a list of functions and commands for that topic. Detailed help can then be obtained for any of those commands and functions. Here we discuss some basic features of MATLAB. To begin, let us look at the general structure of the MATLAB environment. On almost all systems, MATLAB works through three basic windows, which are discussed here.
1. MATLAB desktop:
This is where MATLAB puts you when you launch it. The MATLAB desktop, by default, consists of the following subwindows.
Command Window:
The MATLAB interpreter displays a command >> indicating that it is ready to accept commands from you. When you launch the application window. All commands, including for running user-written programs, are typed in this window at the MATLAB prompt. You can use the command window as a calculator, or you can use it to call other MATLAB programs
(M-files).
Current Directory pane: This pane i s located o n the left of the Command Window in the default MATLAB desktop layout. This is where all files from the current directory are listed. Workspace pane: This subwindow lists all variables that got generated so far and shows their type and size.
2. Figure Window:
The output of all graphics commands typed in the command window are flushed to the graphics or figure window, a separate gray window with (default) white background color. The user can create as many figure windows as the system memory will allow.
3. Editor window:
This is where we write , edit,create, and save y our own programs in files called M-files. You can use any text editor to carry out these tasks. On most systems, MATLAB provides its own built-in editor. However, we can use our own editor by typing the standard file-editing command that you normally use on our system. Do the following in the command window.

Q. 1: Evaluate the expression a3+ bd − 4c, where a=1.2, b=2.3, c=4.5 and d=4.
Q. 2: Create following two arrays: (a) Array of ones with 10 elements (b) Array a[1] = 2; a[2] = 3 and a[3] to a[10] are zero
Q. 3: Consider the two matrices: A = [4 -6; 6 10] B = [6 -13; 3.4 16] Find (a) A+B (b) B2 (c) AB (d) (AB)T (e) A-B (f) A/B (g) Inverse of A
Q. 4: Find the solution of the following set of linear algebraic equations using matrix algebra AX = b: 5x + 6y + 10z = 4
−3x + 14z = 10
−7y + 21z = 0
Q. 5: Find all integers between 1 and 30 for which their sine is negative.
Q. 6: Plot the following continuous and discrete functions:
(a) y = sin(x)from 0 ≤ x ≤ 2π
(b) y = x2− 10x + 15 from 0 ≤ x ≤ 10
(c) h[n] = {1,2,3,4,5} with n = −2 to 2
Q. 7: Consider the matrix A=[3 2 -2; -3 -1 3; 1 2 0] Compute the
(a)Roots of a characterestic equation of a matrix A
(b) Eigen values and Eigen vectors
M-File Script: A script file is an external file that contains a sequence of MATLAB statements. Script files have a filename extension .m and are often called M-files. M-files can be scripts that simply execute a series of MATLAB statements, or they can be functions that can accept arguments and can produce one or more outputs.
Q. 8: Write MATLAB code for the following:
(a) Create a column vector with 10 values of temperature in degree centigrade C
(b) Convert each of the temperature values in degree Fahrenheit
(c) Make the final matrix with temperature values in C as the first column and inF as the second column.
Q. 9: Create a function file for the Q.10 (a) such that C is taken as input vector and F is an output vector.
Q. 10: Write a function to calculate the factorial for a given integer
Flow Control in MATLAB:
MATLAB has the following flow control constructs:
• if statements
• for loops
• while loops
• break statements.
Q. 11: what is the value of ‘str’ after execution of below code? Example 1
x=-3; if x>0
str=’positive’; elseif x<0 str=’negative’; elseif x== 0
str=’zero’; else str=’error’; end
Q. 12: What is the value of x after execution of the below loop?
Example 2:
x=-10;
while x < 0 x=x+1; end
Q. 13: What is the value of X after execution of the below loop?
Example 3: X=0; for i=1:10
X=X+1; end
Q. 14: Write a function which gives the sum of the first n integers.
Q. 15: What is the value of x after execution of the below code?
Example 4:
x=-10;
while x < 0 x=x+2; if x == -2
break; end end end
Q. 16: Determine the probability of 3 heads in 4 tosses of a coin with probability of head being p=0.75. Use a relative frequency interpretation of probability to yield the result.
Q. 17: Write a MATLAB program that will add all the numbers corresponding to the even indices of an array. For instance, if the array x was x=[1, 3, 5, 10], then it should return 13 (= 3 + 10). Use that program to find the sum of all even integers from 1 to 1000. Write your program so that it is flexible. That is, you should be able to invoke your program from the command window as follows:
>> y=addeven(x) where x is the input vector, and y is the sum of all the numbers corresponding to the even indices of x.

Reviews

There are no reviews yet.

Be the first to review “MA202 – IIIT Vadodara Solved”

Your email address will not be published. Required fields are marked *

Related products