Basics of MATLAB | Chapter 3



Data Types

There are 15 Data types in MATLAB.

double, single
Floating-point numbers
Int8,uint8
Int16,uint16
Int32,uint32
Int64,uint64
Integers
char
Characters & String
logical
Logical class
function_handle
Function Handles
struct
Structure
cell
Cell Array



Some Data Type conversion in MATLAB
>>char                            Character array
>>int2str                         Int data to string
>>mat2str                       Matrix data to string
>>num2str                      Number to str
>>str2double                  String to double precision
>>str2num                      String to number
>>native2unicode           Numeric byte to unicode
>>unicode2native           Unicode to numeric byte
>>base2dec base             Number string to decimal
>>bin2dec binary            Number to decimal
>>dec2base                     Decimal to base number string'
>>dec2bin                       Decimal number to binary
>>dec2hex                      Decimal to hexa
>>hex2dec                      Hex to decimal number
>>hex2num                     Hex to number string
>>cell2mat                      Cell array to numeric
>>cell2struct                   Cell array to structure
>>mat2cell                      Convert array into cell
>>num2cell                     Convert number string into cell
>>struct2cell                    structure to cell array

Programming:


In MATLAB programme is written on editor window before writing a programme we need to know about it.
-clc       it clears the command window
-clear it clears the workspace

Statements and their use.

  • The if statement
  • The switch statement
  • The for Statement
  • The while statement
If- else statement use:

Find a Number it's EVEN or ODD ?






Switch-Case statement use:


A shop model, switch-case used.



For statement use:

To Find factorial of any given number ?



Note: In Matlab factorial function is there, factorial(x) we can find factorial of any number.

While statement use:



Note: To terminate while loop use ctrl+c .

There are more statements like try and catch and etc.

Comments