Programming and Developing Algorithms with MATLAB
Write programs and develop algorithms using the high-level language and development tools in MATLAB®.
Published: 7 Sep 2012
MATLAB provides a high-level language and development tools that let you quickly write MATLAB programs, develop and analyze algorithms, and build applications. MATLAB is a matrix-based language. It natively supports vector and matrix operations that are fundamental to engineering and scientific problems.
For example, you can operate on all of the elements in a matrix with a single command without having to write a for loop. As a result, one line of MATLAB code often replaces several lines of C or C++ code.
MATLAB provides features of traditional programming languages, including flow control, such as while and for loops; error handling, such as try catch blocks which allow us to execute statements and catch the resulting errors; and object-oriented programming. Here you can see a class defined in MATLAB together with its properties and methods.
The MATLAB environment is well suited for algorithm design and exploration. In this example, we're developing an algorithm to identify the center of a hurricane. Because MATLAB is a high-level language there's no need to perform low-level administrative tasks, such as declaring variables, specifying data types, and allocating memory.
Using the Command window, you can execute commands one at a time, providing you with immediate results. This interactive approach makes it easy to quickly explore multiple options and iterate to an optimal solution.
You can create a MATLAB script or function from the commands you've already entered. This makes it easy to reuse and automate your work. MATLAB provides built-in algorithms for signal processing and communications, image and video processing, control systems, and many other domains. Here, we're using a function from Image Processing Toolbox™ to identify and measure properties of connected regions in an image.
MATLAB provides development tools that help you implement your algorithms efficiently and optimize their performance. The MATLAB editor is where you create and edit programs. The editor provides debugging features. You can set breakpoints, examine variable values, and step through individual lines of code.
The Code Analyzer automatically checks code in the MATLAB editor for problems. When you hover over underlined code fragments, the Code Analyzer provides an explanation of the problem and suggestions on how to fix it. The MATLAB Profiler measures the overall performance of MATLAB programs and identifies areas of code to focus on for improvement. The Profile Summary report gives information about the functions called, including the time each function took to run, how many times each function was called, and which lines of code took the most processing time.
You can integrate your MATLAB applications with those written in other languages, such as C, C++, Java, and .NET. Here we have C code for a 2D Gaussian function. This code was compiled into a MEX function, or MATLAB executable, and can be called directly from within MATLAB. Similarly, you can call MATLAB code directly from your C, C++, or FORTRAN applications.
MATLAB uses processor-optimized libraries for fast execution of matrix and vector computations. Many linear algebra and numerical functions are multi-threaded, allowing them to run faster on multicore computers. You can use the high-level constructs found in the parallel computing products to parallelize your applications with only minor code changes. This allows you to take further advantage of multicore desktops and other resources, such as GPUs and clusters. With MATLAB you can easily transform your ideas into algorithms and complex applications.
For more information about MATLAB, see the product page or watch one of the other videos.
Featured Product
MATLAB
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)