Time to Program

For the past week, I had three problems which I had to use Matlab to solve. I did not have much experience about programming in Matlab. However, I was writing a C language program in the summer for my internship. I gained some programming tips and debugging skills over the summer. Even though Matlab is a different language, but the method for writing codes will be the same.

1. Name your variables wisely

Every variable exists for a reason. Therefore, name the variable in a way that other people can understand. For one of the program I wrote, I needed 4 different counters for different reasons. I named them, c, counter, cnt, cntr. Later I discovered that I was supposed to use cnt for a variable but I typed in counter. As a result, naming variables wisely is really important especially when your program become long.

2. Google is your best friend

Matlab is powerful, there are a lot of things it can do. However, I do not know the commands. Therefore, I Google all the time. For the assignment I had, I was play around with matrix properties and symbolic toolbox. I just described what I want Matlab to do, and Google will give me the right command.

3. Watch how your variable change

When your program start act differently than you expected, it is time for debugging. Do not just look over your code, and think that is OK. In case of Matlab, after you run a script, you can play around with your code in the command window. For example, I used A=zeros(2,2), and later I need to derive a symbolic expression and plug in into the matrix A. It gave me an error. Therefore, I typed in A=zeros(2,2), and declared a symbolic s. I made A(1,1)=s. Matlab prompted me that  “The following error occurred converting from sym to double:”. OK. time to play around with matrix. I declared another symbolic variable a, and made A=[a,a;a,a]. Then, I made A(1,1) to s. It is working! After playing with the command window for trial and error, I know I need to change for my original script.


As an electrical engineering student, I love to program, and I enjoy the time for debugging. Computer only understands 0 and 1. If he said I am wrong, then I am wrong. So I have to understand how he reacts differently to my code. I spent lots of hours in those assignments, and I thought that was a pleasure for me. I just uploaded all my codes to Course Site for TA to grade. It is time for another homework. This is what a junior year at Lehigh suppose to be.



About lueva15

Hi, everyone. This is Eva Chen from Integrated Business and Engineering Program studying Electrical Engineering at Lehigh. This is my third year, and I am excited to share my Lehigh experience with you.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s