TOPICS

Thursday, April 14, 2011

MATLAB AN INTRODUCTION (PART 1)

MATLAB is a matrix-based computer system designed for scientific and engineering problem solving. The name MATLAB stands for Matrix Laboratory, because the system was designed to make matrix computations particularly easy. A matrix is an array of numbers organized in m rows and n columns. An example is the following m × n = 2 × 3 array:

Any one of the elements in a matrix can be taken out by using the row and column indices that identify its location. The elements in this example are taken out as follows: A(1, 1) = 1, A(1, 2) = 2, A(1, 3) = 3, A(2, 1) = 4, A(2, 2) = 5, A(2, 3) = 6. The first index identifies the row number counted from top to bottom; the second index is the column number counted from left to right. This is the convention used in MATLAB to locate information in an array.

You input commands to MATLAB in the Command Window. MATLAB returns output in two ways: typically, text or numerical output is returned in the same Command window, but graphical output appears in a separate figure window.

Arithmetic

MATLAB does arithmetic like a calculator. For simple arithmetic operations simply enter the command in the command line and press enter

2+3 Press Enter ans = 5

2-3 Press Enter ans = -1

2*3 Press Enter ans = 6

2/3 Press Enter ans = 0.6667

In above examples MATLAB prints the answer and assigns the value to a variable called ans. MATLAB uses double-precision floating-point arithmetic, which is accurate to approximately 15 digits; however, MATLAB displays only 5 digits by default.

Variables

Variable is a quantity that can assume any of a set of values. To assign a value of 3 to a variable ‘a’

a=3 Press Enter

The ‘a’ is a variable. This statement assigns the value of 3 to it.

Common commands

  • The clear command clears all the values assigned to variables. Clear a will only clear the value assigned to variable a
  • The command ‘whos’ is executed to determine the list of local variables or commands presently in the workspace.
  • The semicolon (;) when placed in front of a variable, prevents its value from being displayed on the screen.
  • clc stands for clear command window and clears the workspace.
  • Pressing the up arrow key recalls all your previous commands without the need for you to retype.
  • Enter quit or exit at the Command Window prompt will exit the software.

Vectors

When you assign values to variables such as a=2 and b =4, these are called scalars; because they are single-valued. MATLAB also handles vectors (generally referred to as arrays; array a collection of data items that are given a single name).The easiest way of defining a vector where the elements increase by the same amount is with a statement like

x=0:10

x = 0 1 2 3 4 5 6 7 8 9 10

To find its size give the following command

Size(x)

ans = 1 11 (means that it has single row and eleven columns)

MATLAB is case-sensitive, which means it distinguishes between upper and lowercase letters. Thus, logic, LOGIX and Logic are three different variables

Mathematical functions

MATLAB has all of the usual mathematical functions found on a scientific electronic calculator, like sin, cos and log.

>> sin(90)

ans = 0.8940 (You get the answer in radians)

Graph

a=1:5;

b=6:10;

plot(a,b),grid

Above command assigns values 1 to 5 to variable a and values 6 to 10 to variable b. Plot command plots a on x axis and b on y axis

10 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This post is a helpful overview of the particular topic and very actionable. Interesting approach!
    extension springs supplier in Delhi.

    ReplyDelete
  3. If you're looking to lose fat then you absolutely have to try this brand new custom keto meal plan.

    To create this keto diet, licensed nutritionists, personal trainers, and cooks have joined together to develop keto meal plans that are powerful, decent, cost-efficient, and delicious.

    Since their grand opening in January 2019, thousands of people have already completely transformed their body and well-being with the benefits a good keto meal plan can give.

    Speaking of benefits: clicking this link, you'll discover 8 scientifically-proven ones offered by the keto meal plan.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Your website is very beautiful or Articles. I love it thank you for sharing for everyone. Ucat practice exam

    ReplyDelete
  6. Hey! Nice Blog, I have been using QuickBooks for a long time. One day, I encountered QuickBooks Support Number in my software, then I called QuickBooks Support Number They resolved my error in the least possible time.

    ReplyDelete
  7. Your blog is very nice and we hope you are providing more information in future times.

    QuickBooks Error 6189










    ReplyDelete

  8. Nice and Creative Blog!! I really want to read more content of your blog, please keep posted regularly!!if you are facing any issue in QUICKBOOKS, please visit:

    quickbooks Customer Service

    ReplyDelete
  9. It is a great sharing me...I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article.
    Electrician in Islamabad

    ReplyDelete
  10. Hey! Fabulous post. It is the best thing that I have read on the internet today. Moreover, if you need instant support for QuickBooks Error, visit at QuickBooks Customer Support Number Our team is always ready to help and support their clients.

    ReplyDelete