Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Matlab

you can download suggested book from http://www.cse.cuhk.edu.hk/~cslui/CSCI1050/book.pdf

x=1/3

x =

0.3333

format long g
x=1/3

x =

0.333333333333333

format short
x=1/3

x =

0.3333
c=200.56

c =

200.5600

d=6

d =

e=d^c

e =

1.1642e+156

Scietific Calculator
sqrt(2)

ans =

1.4142

format long
sqrt(2)

ans =

1.414213562373095

For 100 decimals

vpa(ans,100)

ans =

1.4142135623730950488016887242096980785696718753769480731766797379907324784621070
38850387534327641573

tan(pi/4)

ans =

1.000000000000000

tand(45)

ans =

1
log(2)

ans =

0.693147180559945

log10(2) log 10
ans =

0.301029995663981

isnan(0/0)

ans =

logical

isnan(1/0)

ans =

logical

physconst Physical constants of natural phenomena

k=physconst('Boltzman')

k =

1.380650400000000e-23

c=physconst("Lightspeed")

c =

299792458

R=physconst("EarthRadius")
R =

6371000

% roots of polynomial
p=[2 0 0 -1 0 0 1 -4] %2x^7-x^4+x-4=0

p =

2 0 0 -1 0 0 1 -4
roots(p)

ans =

-0.984679790975369 + 0.553047500894175i
-0.984679790975369 - 0.553047500894175i
-0.264344424686305 + 1.119223342047483i
-0.264344424686305 - 1.119223342047483i
1.121391663931368 + 0.000000000000000i
0.688328383695989 + 0.763875273691798i
0.688328383695989 - 0.763875273691798i

R=roots(p)

R =

-0.984679790975369 + 0.553047500894175i
-0.984679790975369 - 0.553047500894175i
-0.264344424686305 + 1.119223342047483i
-0.264344424686305 - 1.119223342047483i
1.121391663931368 + 0.000000000000000i
0.688328383695989 + 0.763875273691798i
0.688328383695989 - 0.763875273691798i

R(4)

ans =

-0.264344424686305 - 1.119223342047483i
who

Your variables are:

R ans c k p

whos
Name Size Bytes Class Attributes

R 7x1 112 double complex


ans 1x1 16 double complex
c 1x1 8 double
k 1x1 8 double
p 1x8 64 double

pwd

ans =

'/MATLAB Drive'

for n=1:10 %for loop


x(n)=n^2;
end

Ans will be in workspace

x =

1 4 9 16 25 36 49 64 81 100
(1)

ans =

x(2)
ans =

4
x(0)
Array indices must be positive integers or logical values.

Triangle numbers

n=1;
while n<=5
t(n)=n*(n+1)/2
n=n+1;
end

figure
cplxroot(5)
 
cplxroot Riemann surface for the n-th root.
cplxroot(n) renders the Riemann surface for the n-th root.

You might also like