Sie sind auf Seite 1von 12

MATLOGIX 2012

FINAL ROUND PROBLEM STATEMENTS


Rules and regulations:1. There are 10 questions each of 10 marks comprising 100 marks in total. 2. The participants have to submit whatever they have completed before 2:00 pm on 01.04.2012 by mailing their solutions to matlogix2012@gmail.com. 3. Incase internet connection is not available at the time of sending the solutions, the softcopy of the solutions ( .m files) can be submitted to a) for boys - - Abhishek kumar , Room No. 319, Hostel -G b) for girls - -Rashmi kumari , Room no. 213, Hostel Ambedkar hostel 3. The teams can contact for any queries regarding questions or for any general MATLAB queries-ABHISHEK KUMAR(9905463270) ACHAL JAIN (9939476186) 4. There is no limitation on usage of inbuilt functions.

1. A) Imagine a train had acceleration a=2t where t is in seconds, a is in m/s


The velocity at t=2 s was 180 km/h. Write a MATLAB program to (a) Create a time vector that goes from t=2 to t=4 seconds. (b) Create an acceleration vector at those times using the above function (a=2t). (c) Plot acceleration vs. time. (d) Use the trapz command to numerically integrate the acceleration from 2 to 4 seconds to compute the change in velocity between 2 and 4 seconds. Add this to the initial velocity of 180 km/h given at t=2 s to compute the velocity at 4 seconds. Print the value obtained. (e) Now use the cumtrapz command to numerically integrate the acceleration from 2 to 4 seconds cumulatively, to produce a change in velocity which is now a function of time. Add this to the initial velocity (180 km/h expressed in m/s) to get the velocity as a function of time. (f) Plot velocity vs. time. (g) Integrate the velocity vs. time using trapz to compute the total change in distance from 2 to 4 seconds. Print the value obtained.

B) A small rocket is being designed to make wind shear measurements in the vicinity of thunderstorms. Before testing begins, the designers are developing a simulation of the rocket's trajectory. They have derived the following equation that they believe will predict the performance of the test rocket, where t is time elapsed in seconds. The equation gives the height above the ground level at time t. The first term (60) is the height above ground level of the nose of the rocket. height = 60 + 2.13t2 0.0013t4 + 0.0003t4.571 a) Write a program to compute and print the time and height of the rocket from t = 0 to the time that it hits the ground, in increments of 2 secs. If the rocket has not hit the ground within 100 secs, stop the program. b) Modify the program such that instead of a table, the program prints the time at which the rocket begins falling back to the ground and time at which the rocket impacts.

2. a) The following is a method of computing :


1. Let A=1 and N=6 2. Repeat 10 times, say: Replace N by 2N Replace A by [2(4A2)]1/2 Let L=NA/2 Let U=L/ (1A2/2) Let P = (U+L)/2 (estimate of ) Let E = (UL)/2 (estimate of error) Print N, P, E 3. Stop. Write a program to implement the algorithm.

b) Write a function function [x1, x2, flag] = quad( a, b, c ) which computes the roots of the quadratic equation ax2 +bx +c = 0. The input arguments a, b and c (which may take any values) are the coefficients of the quadratic, and x1, x2 are the two roots (if they exist), which may be equal. The output argument flag must return the following values, according to the number and type of roots: 0: no solution (a=b=0, c 0); 1: one real root (a=0, b 0, so the root is c/b); 2: two real or complex roots (which could be equal if they are real); 99: any x is a solution (a=b=c=0).

3. Given a string of characters, we can permute the individual characters to make new
strings. If we can impose an ordering on the characters (say alphabetic sequence),then the strings themselves can be ordered and any given permutation can be given a unique number designating its position in that ordering. For example the string `acab' gives rise to the following 12 distinct permutations:

Thus the string `acab' can be characterized in this sequence as 5. Write a MATLAB program that will read in a string and determine its position in the ordered sequence of permutations of its constituent characters.

Input and Output


Input will consist of a series of lines, each line containing one string. Each string will consist of up to 30 lower case letters, not necessarily distinct. Output will consist of a series of lines, one for each line of the input. Each line will consist of the position of the string in its sequence.

Sample input
bacaa abc cba

Sample output
15 1 6

4. The Hamming distance between two strings of bits (binary integers) is the number of
corresponding bit positions that differ. This can be found by using XOR on corresponding bits or equivalently, by adding corresponding bits (base 2) without a carry. For example, in the two bit strings that follow:
A 0 1 0 0 1 0 1 0 0 0 B 1 1 0 1 0 1 0 1 0 0 A XOR B = 1 0 0 1 1 1 1 1 0 0

The Hamming distance (H) between these 10-bit strings is 6, the number of 1's in the XOR string.

Input
N, the length of the bit strings and H, the Hamming distance.

Output
A list of all possible bit strings of length N that are Hamming distance H from the bit string containing all 0's (origin). That is, all bit strings of length N with exactly H 1's.

The program should work for 1<=N<=10 and 1<=H<=10.

Sample
For N=4 and H=2 the output should contain all of the following bit strings (order is unimportant):
0011 0101 0110 1001 1010 1100

C(4, 2) is 6.

5. In traditional "long multiplication" we determine the product of two integers, x and y,


by multiplying x and the individual digits of y, in turn, starting with the unit digit. The results of these multiplications are arranged appropriately and added, yielding the completed product. The representation of these operations is usually done in a particular manner. Consider the multiplication of 123 by 95:
123 95 --615 1107 ----11685

The numbers to be multiplied, x and y, are each displayed on a separate line, followed by a horizontal line. The results of multiplying each digit of y by x are then displayed on separate lines, followed by another horizontal line, and then the final product. In this problem you are to perform a sequence of such multiplications, displaying the results in this traditional representation.

Input
Each line of the input data, except the last, will contain two integers, x and y, separated by whitespace (one or more blanks and tab characters). Each integer will have no more than 10 digits. The last line of the input data will contain only whitespace, and marks the end of the input.

Output
For each pair of integers (that is, each input line except the last), perform the multiplication of x by y, displaying the results in the form shown above and in the examples shown below. Follow the output for each multiplication by a blank line. If y contains only a single significant digit, omit the second horizontal line and the sum (since in that case it would be superfluous). Display 0 digits only when they are significant. The number of hyphens in the first horizontal line should be the same as the number of digits in the larger of x and y. The number of hyphens in the second horizontal line, if it is produced, should be the same as the number of digits in the product of x and y.

Example Input
4 7 135 46 this line is blank

Expected Output
4 7 28 135 46 --810 540 ---6210

6. Write a program that has to decide whether a given line segment intersects a given
rectangle.

An example:
line: start point: (4,9) end point: (11,2) rectangle: left-top: (1,5) right-bottom: (7,1)

Figure 1: Line segment does not intersect rectangle The line is said to intersect the rectangle if the line and the rectangle have at least one point in common.

Input
The input consists of n test cases. The first line of the input file contains the number n. Each following line contains one test case of the format: xstart ystart xend yend xleft ytop xright ybottom where (xstart, ystart) is the start and (xend, yend) the end point of the line and (xleft, ytop) the top left and (xright, ybottom) the bottom right corner of the rectangle. The eight numbers are separated by a blank. The terms top left and bottom right do not imply any ordering of coordinates.

Output
For each test case in the input file, the output file should contain a line consisting either of the letter "T" if the line segment intersects the rectangle or the letter "F" if the line segment does not intersect the rectangle.

Example

Input
1 4 9 11 2 1 5 7 1

Output: F

7. A common component in electronic circuits is the resistor. Each resistor has two
terminals, and when current flows through a resistor, some of it is converted to heat, thus resisting the flow of the current. The extent to which it does this is indicated by a single positive numeric value, called the resistance of the resistor having a unit ohm. When two or more resistors are connected in series, as shown below, then their equivalent resistance is just the sum of the resistances of the individual resistors. For example, if the two resistors below had resistances of 100 and 200 Ohms, respectively, then the combined resistance (from point A to point B) would be 300 Ohms.

Resistors may also be connected in parallel, like this:

If these two resistors had resistances of 100 and 150 Ohms, then the parallel combination would yield an equivalent resistance between points A and B of

In this problem you're provided one or more descriptions of resistors and their interconnections. Each possible interconnection point (the terminals of a resistor) is identified by a unique positive integer, its label. And each resistor is specified by giving its two interconnection point labels and its resistance (as a real number). For example, the input
1 2 100

would tell us that a 100 Ohm resistor was connected between points 1 and 2. A pair of resistors connected in series might be specified like this:
1 2 2 3 100 200

Here we've got our 100 Ohm resistor connected at points 1 and 2, and another 200 Ohm resistor connected to points 2 and 3. Two resistors in parallel would be similarly specified:
1 1 2 2 100 150

Once you know how the resistors are interconnected, and the resistance of each resistor, it's possible to determine the equivalent resistance between any two points using the simple rules given above. In some cases, that is. Some interconnections of resistors can't

be solved using this approach--you won't encounter any of these in this problem, however.

Input
There will be one or more cases to consider. Each will begin with a line containing three integers N, A, and B. A and B indicate the labels of points between which you have to determine the equivalent resistance. N is the number of individual resistors and will be no more than 30. N, A and B will all be zero in the line following the last case. Following each "N A B" line will be N lines, each specifying the labels of the points where a resistor is connected, and the resistance of that resistor, given as a real number.

Output
For each input case, display a line that includes the case number (they are numbered sequentially starting with 1) and the equivalent resistance, accurate to two decimal places.

Sample Input
2 1 3 1 2 100 2 3 200 2 1 2 1 2 100 1 2 150 6 1 6 1 1 3 3 4 5 0 0 0

2 3 4 5 6 6

500 15 40 100 60 50

Sample Output
Case 1: 300.00 Ohms Case 2: 60.00 Ohms Case 3: 75.00 Ohms

8. A tree is a well-known data structure that is either empty (null, void, nothing) or is a
set of one or more nodes connected by directed edges between nodes satisfying the following properties. 1. There is exactly one node, called the root, to which no directed edges point. 2. Every node except the root has exactly one edge pointing to it. 3. There is a unique sequence of directed edges from the root to each node. For example, consider the illustrations below, in which nodes are represented by circles and edges are represented by lines with arrowheads. The first two of these are trees, but the last is not.

In this problem you will be given several descriptions of collections of nodes connected by directed edges. For each of these you are to determine if the collection satisfies the definition of a tree or not.

Input
The input will consist of a sequence of descriptions (test cases) followed by a pair of negative integers. Each test case will consist of a sequence of edge descriptions followed by a pair of zeroes Each edge description will consist of a pair of integers; the first integer identifies the node from which the edge begins, and the second integer identifies the node to which the edge is directed. Node numbers will always be greater than zero.

Output
For each test case display the line "Case k is a tree." or the line "Case k is not a tree." where k corresponds to the test case number (they are sequentially numbered starting with 1).

Sample Input
6 8 5 6 8 1 7 4 5 3 0 0 7 3 7 8 5 2 6 4

Expected Output
Case 1 is a tree. Case 2 is a tree. Case 3 is not a tree. 7 5

6 2 7 6 6 4 5 2

8 9 0 0

3 8 6 8 5 3 5 6 -1 -1

0 0

9. Just as the electric field gives the force on a test charge, the electric potential gives the
potential energy on a test charge. Given the electric potential, V(x,y), the electric field is

The magnitude of the electric field is largest where the derivatives of the potential are maximum. It is often useful to look at contours of constant potential since the electric field points in the direction of the gradient, that is, if the contours were to form a topological map of a mountainous terrain then the electric field at a location would point in the downhill direction. The algorithm which computes the electric field E(x,y) for a given potential V(x,y) and graphs both in the xy plane, is outlined below: Initialize variables (e.g., potential V(x,y), graphics). Evaluate electric field as Ex = V/ x and Ey = V/ y. Loop over all grid points and evaluate V(x,y) and E(x,y) on grid. Compute potential at the grid point. Compute components of the electric field. Normalize E-field vectors to unit length. Plot contours of constant electric potential. Add electric field direction to potential contour plot

Write the program in MATLAB for the given algorithm. For the potential

the program should produce the contour and wiremesh plots of the potential. The contour plot shows the electric field direction.

10(A).To play Chirp in reverse order, count no. of samples, find peak amplitude and it's location and Set all those amplitudes to 0.8 (B) To plot x=cos(t) and y=exp(-t)cos(10*t) on same axis and generate surface normals using quiver for function R=cos(x).*sin(0.5.*x).*exp((x.*x)/200);

Das könnte Ihnen auch gefallen