A blog to help electrical engineers and students to learn electrical engineering topics. Basic Electrical Engineering, Power Systems, Electrical Machines, tec.. Now special course on MATLAB for Beginners.

Class

Class

Wednesday, February 22, 2017

Methods to Improve the Calculation Speed of MATLAB Programs - Part 1

Introduction

Speed of execution of code is an important issue for all coders. In this lecture we will discuss some programming practices to improve the performance of MATLAB code.
Analyzing Performance of the Code 

MATLAB has some built is tools to help the coder to analyse the performance of his code. The two main tools are The M-file Profiler graphical user interface and the stopwatch timer. These tools help the coder to check information on how the program is performing

The M-File Profiler

Profiler help you to analyse the performance of the code and determine where you can modify your code to improve performance. M-file Profiler, a graphical user interface that shows you where your program is spending its time during execution. The Profiler can be more useful in measuring relative execution time and in identifying specific performance bottlenecks in your code.

Running the Profiler
Use one of the following methods:
  • On the Editor tab, in the Run section, click Run and Time. If you use this method, the Profiler automatically profiles the code in the current Editor tab.
  • On the Home tab, in the Code section, click Run and Time.
  • In the Command Window, type profile viewer.



Stopwatch Timer Functions ( tic and toc)
Stopwatch functions is a tool which provide absolute time measurements of execution for your code.If you just need to get an idea of how long your program takes to run, or to compare the speed of different implementations of a program, you can use the stopwatch timer functions.. Invoking tic starts the timer, and the first subsequent toc stops it and reports the time elapsed between the two.

Syntax:
tic
run the program section to be timed
toc

Shorter programs will run too fast it may be difficult to use timer function. In this case, we can measure the time by running the program repeatedly in a loop, and then average to find the time for a single run.
tic
for k = 1:100
run the program
end
toc

submit to reddit

8 comments:

  1. Its looking Very Nice. Thanks for giving full information about Electrical Engineering Courses.

    ReplyDelete
  2. It is very useful information. Thank you. For more information related to this Click here

    ReplyDelete
  3. It is really very helpful to improve calculation speed of matlab program , do read the whole blog , if looking for more information about Electronics Engineering, Visit:
    Electronics Engineering

    ReplyDelete
  4. The above Explanation for Methods to Improve the Calculation Speed of MATLAB Programs - PART 1 is really very qualitative i would like o refer the content to all the Electrical Engineering students, Learn Electrical Engineering with Our Adaptable Online Videos Course Materials Video Lectures on Electrical Engineering from Superior Faculty

    ReplyDelete
  5. Great post i must say and thanks for the information.I appreciate your post and look forward to more.
    For any graphtec data logger
    For any Data Logger Dealers
    For any graphtec dealers
    For any graphtec data logger gl840

    ReplyDelete
  6. The electrical polarization control of magnetic properties is an emerging field of research that explores the manipulation of magnetic properties using electrical means. This concept has opened up new possibilities for advanced memory applications, leading to the development of innovative devices with enhanced functionality.
    As an Richmond consulting firms, you have a wide range of opportunities to apply your skills and expertise in various industries and sectors.

    ReplyDelete