Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Bashuk Kirill / report5_arch.docx
Скачиваний:
6
Добавлен:
20.02.2016
Размер:
220.48 Кб
Скачать

Errors and Warnings

No matter how carefully you plan and test the programs you write, they may not always run as smoothly as expected when executed under different conditions. It is always a good idea to include error checking in programs to ensure reliable operation under all conditions.

In the MATLAB software, you can decide how your programs respond to different types of errors. You may want to prompt the user for more input, display extended error or warning information, or perhaps repeat a calculation using default values. The error-handling capabilities in MATLAB help your programs check for particular error conditions and execute the appropriate code depending on the situation.

When MATLAB detects a severe fault in the command or program it is running, it collects information about what was happening at the time of the error, displays a message to help the user understand what went wrong, and terminates the command or program. This is called throwing an exception. You can get an exception while entering commands at the MATLAB command prompt or while executing your program code.

Like error, the warning function alerts the user of unexpected conditions detected when running a program. However, warning does not halt the execution of the program. It displays the specified warning message and then continues.

Warnings also differ from errors in that you can disable any warnings that you do not want to see. You do this by invoking warning with certain control parameters. See Warning Control for more information.

Dates and Times Date formats

Video Formats

Video data is a series of images over time. Video in binary or intensity format is a series of single images. Video in RGB format is a series of matrices grouped into sets of three, where each matrix represents an R, G, or B plane.

Video Data Stored in Column-Major Format

The MATLAB technical computing software and Computer Vision System Toolbox blocks use column-major data organization. The blocks' data buffers store data elements from the first column first, then data elements from the second column second, and so on through the last column.

If you have imported an image or a video stream into the MATLAB workspace using a function from the MATLAB environment or the Image Processing Toolbox, the Computer Vision System Toolbox blocks will display this image or video stream correctly. If you have written your own function or code to import images into the MATLAB environment, you must take the column-major convention into account.

Image Formats

In the Computer Vision System Toolbox software, images are real-valued ordered sets of color or intensity data. The blocks interpret input matrices as images, where each element of the matrix corresponds to a single pixel in the displayed image. Images can be binary, intensity (grayscale), or RGB.

Current date and time

The functions todayandnowreturn serial date numbers for the current date, and the current date and time, respectively.

Obtaining user input

Prompting for keyboard input

keyboard, when placed in a program .m file, stops execution of the file and gives control to the keyboard. The special status is indicated by aKappearing before the prompt. You can examine or change variables; all MATLAB commands are valid. This keyboard mode is useful for debugging your functions.

To terminate the keyboard mode, type return, and then press Enter. To terminate keyboard mode and exit the function, typedbquit, and press Enter.

Pausing during execution

pause, by itself, causes the currently executing function to stop and wait for you to press any key before continuing. Pausing must be enabled for this to take effect. (See pause on, below).pausewithout arguments also blocks execution of Simulink models, but not repainting of them.

Shell escape functions

It is sometimes useful to access your own C or Fortran programs using shell escape functions. Shell escape functions use the shell escape command ! to make external stand-alone programs act like new MATLAB functions. A shell escape function

  1. Saves the appropriate variables on disk.

  2. Runs an external program (which reads the data file, processes the data, and writes the results back out to disk).

  3. Loads the processed file back into the workspace

Optimizing MATLAB code

Unrolling for-loops

Unrolling for-loops eliminates the loop logic by creating a separate copy of the loop body in the generated code for each iteration. Within each iteration, the loop index variable becomes a constant. By unrolling short loops with known bounds at compile time, MATLAB generates highly optimized code with no branches.

You can also force loop unrolling for individual functions by wrapping the loop header in a coder.unroll function. For more information, see coder.unroll.

Inlining code

MATLAB uses internal heuristics to determine whether or not to inline functions in the generated code. You can use the coder.inline directive to fine-tune these heuristics for individual functions. For more information, see coder.inline.

Eliminating Redundant Copies of Function Inputs (A=foo(A))

Rewriting Logical Array Indexing as a Loop

  1. Conclusion

I have studied MATLAB language fundamentals.

4. References

Lab_5 CA_Sec.pdf . Romanov E.I. 1p.

Lec_5_CA_engl.pdf . Romanov E.I. 8p.

Help of MatLab R2012a (7.14.0.739). The MathWorks Inc. 1984-2012

Official link of software: http://www.mathworks.com/

Соседние файлы в папке Bashuk Kirill