Skip to main content

FundaTip1 : Script File

Why commenting is important in programming?


While writing a program in script file, it is always recommended to add comments. Comments will help reader to understand following things  -
  1. Project title and details about the same. 
  2. Purpose of variables used, in mathematical equations. 
  3. Declaration of given data variables. 
  4. Units of the given variable and output variable. 
  5. Assumptions made while working with mathematical model in your project.
Let's take a look at the example below - 

A program without comments. 


In the example above we are not able to understand what is tC, CwT or rC. Even with oak and pine variables, its difficult to understand why those values? And what is its unit? What is the goal of the program? 

But with comments reader can easily understand the purpose of program, goal of a programmer, the units of variable and nomenclature of input variables.

A program with comments.


A program with simple comments is very much easy to understand.

This will very much help you in your projects, when a project duration is across a year and when you want to refer your own first programs.

Try best practice and be a pro-programmer with simple and easy tips and tricks. 

Comments

Popular posts from this blog

FundaTip3: Script File

Some important functions you should not forget! In mathematical programming environment, it is really necessary for us to know various functions which can perform fundamental operations. I am sharing a curated list of functions which are very much useful while programming mathematical models in MATLAB. Fundamental mathematical functions you should know. Let's take some examples to experience the use of these functions - Commands used in simple mathematical equations.  Variables 'a' , 'b' are defined by user, which are known as independent variables . Variables 'x' and 'y'  are output of some mathematical operation of 'a' and 'b', which is known as dependent variable .  Simple but important mathematical functions used in equations. 'Log' denotes the natural log  and 'Log10'  denotes the log to the base 10. Please do not get confuse with analytical commands or commands in scientific ...

Welcome to my blog!

Dear fellow engineers, w elcome to the bog MATLAB Tips & Tricks. This blog is all about interesting tips and tricks that are useful in MATLAB and Simulink, for quick and efficient programming. Generally experts and coders with more experience use them to get done with codes or mathematical models in Simulink. MATLAB being a mathematical programming environment, it is used by researchers, academicians and industry professionals. Because of the tools which are present in MATLAB, makes it more versatile and useful for wide range of applications.  Rupesh Gosavi started his practice with MATLAB in the year of 2013, during his post-graduation. With this blog he wants to spread the knowledge of MATLAB and Simulink, which he gained over the practice of more then 7 years. He is holding a graduation degree in mechanical engineering and post-graduation in automobile technology. During his post-graduation studies, he found MATLAB being a most interesting, dynamic and research oriented l...