You are on page 1of 15

SHRISHAIL HAMINE B.

TECH (MECHANICAL)

disp(Hello!!)

or

disp(x1)

X1=input(Please enter the number) clc //clear screen

comment line

or

/*lines*/

a=32
b=a*34 c=b+2*a

default value

pi=3.14156

a=sqrt(b)
a=power(b,n) a=sin(x) a=asin(b) a=abs(b)

//inverse sine //absolute value

A=zeros(m,n)
A=zeros(m) A=ones(m,n) A=[1

2 3; 4 5 6; 4 5 6] A=1:0.2:10 A=meshgrid(0:0.1:10,0:0.2:100)

A=A+B A=A+6 A=B*6 a=det(A) B=inv(A) A=A^(n)

//add two arrays //add to all elements //multiply to all elements //determinant //inverse

if condition statement1 statement2 else statement3 statement4 end

For a=initvalue:step:finalvalue statement1 statement2 statement3 end


If the step is not mentioned, it is taken to be 1 e.g. for a=1:10 a takes values 1,2,3,

while condition statement1 statement2 end

switch lower(m) case 1: line1 line2 case 2: line3 end

10

line([x1 x2],[y1 y2],color,colour)


colour=b colour=g colour=r blue green red

11

X=0:0.1:100;
Y=f(x); plot(x,y);

axis([x1 x2 y1 y2]);

12

[x,y]=meshgrid(0:0.1:10,0:0.2:100)
Z=f(x,y) surf(x,y,Z) or mesh(x,y,Z)

axis([x1 x2 y1 y2 z1 z2])

13

Declaring function [o1 o2] = func_name (i1) code end //save as func_name.m file
Calling in your program [a1 a2]=func_name([1 2 3 4])

14

csvwrite(filename.txt,A) dlmwrite(filename.txt,A) xlswrite(filename.xls,A) xlswrite(filename.xls,A,sheet) xlswrite(filename.xls,A,sheet,range)

15