Vous êtes sur la page 1sur 4

THEORY The program we used to do our mini project is MATLAB. What is MATLAB?

MATLAB is a high-performance language for technical compution, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familia mathematical notation. The name MATLAB stands for MATrix LABoratory. Matlab is a case sensitive. Typical uses include: o Math and compution o Algorithm development o Data acquisition Modeling, simulation, and prototyping o Data analysis, exploration and visualization o Scientific and engineering graphics o Application development, including graphical user interface building o MATLAB is an interactive system whose basic data element is an array that does not requiring dimensioning. In Academic environment, it is the standard instructional tool for introductory and advanced courses in mathematics, engineering and science. Toolboxes very important to most users of MATLAB , it allow us to learn and apply specialized technology. Toolboxes are comprehensive collections of MATLAB functions (m-files) that extend the MATLAB environment to solve particular classes of problems. Areas in which toolboxes are available include signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many others. The MATLAB system consist of five main parts: o Development Environment This is the set of tools and facilities that help us to use MATLAB functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop and Command Window, a command history, an editor and debugger, and browsers for viewing help, the workspace files, and the search part. o The MATLAB Mathematical Function Library This is a vast collection of computional algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix eigen values, Bessel functions, and fast Fourier transforms. o The MATLAB Language This is a high-level matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features.

o Graphics MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graph. It includes high-level functions for twodimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. It also includes low-level functions that allow you to fully customize the appearance of graphics as well as to build complete graphical user interfaces on your MATLAB applications. o The MATLAB Application Program Interface (API) This is a library that allows us to write C and F ortran programs that interact with MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking) calling MATLAB as a computational engine, and for reading and writing MAT-files.

Programming with MATLAB The MATLAB interactive mode is very useful for simple problems, but more complex problems require a script file. Such a file can be called a computer program, and writing such a file is called programming. The usefulness of MATLAB is greatly increased by the use of decisionmaking functions in its programs. These functions enable you to write programs whose operations depend on the results of calculations made by the program. o While Loops The while loop is used when the looping process terminates because a specified condition is satisfied, and thus the number of passes is not known in advance. A principle of while loops is when we want the loop to continue as long as a certain statement is true. Such a task is often more difficult to do with a for loop. The typical structure of a while loop follows.

o If Loops Every if statement must have an accompanying end statement. The end statement marks the end of the statement that are to be executed if the logical expression, which may be a scalar, a vector, or a matrix. For example, suppose that x is a scalar and that we want to compute y = only if x 0.

In English, we could specify this procedure as follows: If x is greater than or equal to zero, compute y from y = .

ECE123 MINI PROJECT

QUESTION 16 a) Write the program that plays the game of guess the number as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 100. The program then types: I have a number between 1 and 100. Can you guess my number? Please type your first guess. The player the types a first guess. The program responds with the one of the following: d) Excellent! You guessed the correct number. e) Too low. Try again. f) Too high. Try again. If the players guess is incorrect, your program should loop until the player finally gets the number right. Your program should keep telling player Too high or Too low to help the player zero in on the correct answer. Hint : Use fprintf (Your message statement %f\n,variable_name ) Or display (Your message statement) Use While loop

b) Write the program that will ask user to input some numbers and will break/stop asking for input if users enters a negative number. Then compute and display the total sum of all the numbers. Hint: Use for loop.

Vous aimerez peut-être aussi