Posted by : Unknown Tuesday, October 8, 2013

Function

Before defining function, i just tell you about the need of function. Why we use function in our code?
Function makes our program easy and flexible. When we need to repeat some instruction in our program then we use a function.
Then the question is that if we just use function in our program to repeat our code then why we not use loop?
Difference between function and Loop
The answer is, loop execute at a time. It means if the compiler is in the loop then it remain there even the loop not terminate. While we can call function everywhere in our program , when we need.

Function in Matlab



·        Function Definition:

1.function addtwo(x,y)
           x+y
end

2.function area = traparea(a,b,h)
            area = 0.5*(a+b)*h;
end

·        Function Call:
addtwo(5,4)
traparea(5,4,3)

For further information how function write in MATLAB,just visit my post.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Let's Join Us

This blog is for Computer Programming Learner or who is interested in to learn different programming languages

Get Toolbar Free

Get our toolbar!

FeedBurner FeedCount

Computer Problems

Total Pageviews

Popular Post

Labels

About Us

I am a student Of computer Engineering , Studying at UET Taxila. Web development and Programming is my passion. http://about.me/umair.tariq

Top Commentators

Followers

Powered by Blogger.

Recent comments

- Copyright © Computer Problems -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -