17
x 6 := Area circle r () π r 2 := text "tija jan is my name" := Area circle 5 () 78.54 = fun "this is me" := Area cylinder rh , ( ) 2 π r h 2 π r 2 + := a text x 5 < if fun otherwise "this is me" = := Area cylinder 22 , ( ) 50.265 = Angle angle 4 5 , ( ) 51.34 deg = := Angle 0.896 = Changing the ORIGIN of an array ORIGIN 1 := Origin arry can be changed form tools(worksheet option) and build-in variables(array origin) 0 1 2 3 0 1 Mat 20 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 := 2 3 Changing lement 1,1 of an array Mat 11 , 1 := Mat 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 = Adding morre elements to the array Mat 51 , 1 := Mat 52 , 1 := Mat 53 , 1 := Mat 54 , 1 := Mat 55 , 1 := Mat 15 , 1 := Mat 25 , 1 := Mat 35 , 1 := Mat 45 , 1 := Mat 55 , 2 :=

Mathcad - MathCad Lessons

Embed Size (px)

DESCRIPTION

Learn the basics of Mathcad.

Citation preview

Page 1: Mathcad - MathCad Lessons

x 6:=Areacircle r( ) π r

2⋅:=

text "tija jan is my name":=Areacircle 5( ) 78.54=

fun "this is me":=

Areacylinder r h, ( ) 2 π⋅ r⋅ h⋅ 2 π⋅ r2

⋅+:=a text x 5<if

fun otherwise

"this is me"=:=

Areacylinder 2 2, ( ) 50.265=

Angle angle 4 5, ( ) 51.34 deg⋅=:=

Angle 0.896=

Changing the ORIGIN of an array

ORIGIN 1:= Origin arry can be changed form tools(worksheet option)

and build-in variables(array origin)

0 1 2 3

0

1

Mat

20

5

9

13

2

6

10

14

3

7

11

15

4

8

12

16

:=2

3

Changing lement 1,1 of an array

Mat1 1,

1:=

Mat

1

5

9

13

2

6

10

14

3

7

11

15

4

8

12

16

=

Adding morre elements to the array

Mat5 1,

1:= Mat5 2,

1:= Mat5 3,

1:= Mat5 4,

1:= Mat5 5,

1:=

Mat1 5,

1:= Mat2 5,

1:= Mat3 5,

1:= Mat4 5,

1:= Mat5 5,

2:=

Page 2: Mathcad - MathCad Lessons

Mat

1

5

9

13

1

2

6

10

14

1

3

7

11

15

1

4

8

12

16

1

1

1

1

1

2

=

Mat6 6,

66:=

Mat

1

5

9

13

1

0

2

6

10

14

1

0

3

7

11

15

1

0

4

8

12

16

1

0

1

1

1

1

2

0

0

0

0

0

0

66

=

Range Variable

S1 1 2, 10..:= S2 1 0, 10−..:= S3 1 10..:=

the increment the decrease if no second value then it will be 1

S1

1

2

3

4

5

6

7

8

9

10

= S2

1

0

-1

-2

-3

-4

-5

-6

-7

-8

-9

-10

=

rijaS3

π S32

⋅:=

rijaS3

1

1

2

3

4

5

6

7

8

9

10

3.142

12.566

28.274

50.265

78.54

113.097

153.938

201.062

254.469

314.159

=

rija

3.142

12.566

28.274

50.265

78.54

113.097

153.938

201.062

254.469

314.159

=

Page 3: Mathcad - MathCad Lessons

ArrayS1

S12

1+:=

rija10 1,

314.159=

ArrayS1

2

5

10

17

26

37

50

65

82

101

=

Array

1

1

2

3

4

5

6

7

8

9

10

2

5

10

17

26

37

50

65

82

101

= Array10 1,

101=

k 1 4..:= n 1 4..:=

Ahmadk 2n+

k 2n+:=

Ahmad

1

1

2

3

4

5

6

7

8

9

10

11

12

0

0

3

4

5

6

7

8

9

10

11

12

=

Example Problem

Page 4: Mathcad - MathCad Lessons

Density 997.1kg

m3

:=

NetPressure d( ) Density g⋅ d⋅:=

g 9.807m

s2

=

Depths

1

2

4

5

7

17

33

m:=

kPa 1000 Pa⋅=

Pressures NetPressure Depths( ):=

Pressures

9.778

19.556

39.113

48.891

68.447

166.23

322.681

kPa⋅= Depths

1

2

4

5

7

17

33

m=

M

5kg

6lb

3mg

2oz

:= A

3m

s2

5ft

s2

2m

s2

4ft

s2

:=

Page 5: Mathcad - MathCad Lessons

F M A⋅ 19.217 N=:=

F1 M A⋅( )→

:=

F1

15

4.15

0

0.07

N=

F12 1,

4.15 N=

Mat

1

5

9

13

1

0

2

6

10

14

1

0

3

7

11

15

1

0

4

8

12

16

1

0

1

1

1

1

2

0

0

0

0

0

0

66

=

v Mat4⟨ ⟩

:=

v

4

8

12

16

1

0

=

Text max v( ) 16=:=

Page 6: Mathcad - MathCad Lessons

Text1 min v( ) 0=:=

Truncation and rounding function

Va1 3.49:= Va2 3.51:=

T1 floor Va1( ) 3=:= T1 floor Va2( ) 3=:=

T2 ceil Va1( ) 4=:= T2 ceil Va2( ) 4=:=

T3 trunc Va1( ) 3=:= T3 trunc Va2( ) 3=:=

T4 round Va1( ) 3=:= T4 round Va2( ) 4=:=

V1

1

2

3

4

:= V1∑ 10= Ctrl + 3 (Σ)

Page 7: Mathcad - MathCad Lessons

1

5

i

2i

∑=

62= 21

22

+ 23

+ 24

+ 25

+ 62=

y 1:= f y( ) 2y

:=

1

3

j

f y( )∑=

6= 23

23

+ 23

+ 24=

V1

1

2

3

4

=

V15 1,

5:=

V1

1

2

3

4

5

= Sum

1

3

L

V1 L⋅( )∑=

6

12

18

24

30

=:=

Using the Summation operator to calculate the total mass of a struccture

TopFloor 4:=

FirstFloor 1 TopFloor..:=

Volume

1400

1200

1200

1000

m3

:= Density

700

700

700

500

kg

m4

:=

TotalMass

FirstFloor

VolumeFirstFloor

DensityFirstFloor

⋅( )∑ 3.16 106

×kg

m=:=

Mn 1:= Mu 2:=

Page 8: Mathcad - MathCad Lessons

if Mn Mu> "Design is OK", "Design is Not OK", ( ) "Design is Not OK"=

Page223

Interpolation Function

vx1

2

:= vy4

8

:=

εx.T

0.125

0.25

:=

vx0.125

0.25

:= vy24.3

26.6

:=

linterp εx.T θT, , (

linterp vx vy, 0.2, ( ) 25.68=

Time

1

2

3

4

5

s:= Velocity

2.1

3.9

5.9

7.8

10.1

m

s:= xValues

1.5

2.2

0

6

s:=

IntResult linterp Time Velocity, xValues, ( )

3

4.3

0.3

12.4

m

s=:= IntResult

13

m

s=

MathCad Programing

0.5 Factor< 2.0<

Factor x( ) 2 x 2>if

x 0.5 x< 0.5<if

0.5 otherwise

:= F1 Factor 0.25( ) 0.5=:=

F2 Factor 1.0( ) 0.5=:=

F1 Factor 3( ) 2=:=

Page 9: Mathcad - MathCad Lessons

FS d( ) 1.5return d 3.5in≤if

1.4return d 4.5in≤if

1.3return d 5.5in≤if

1.2return d 6.5in≤if

1.1return d 7.5in≤if

1 otherwise

:= FS 6in( ) 1.2=

BB x y, ( ) "Both x and y is in the positive region" x 0> y 0>∧if

"x is in the positive region and y is in reganive" x 0> y 0<∧if

"x is in the negative region and y is in positive" x 0< y 0>∧if

"Both x and y is in the positive region" x 0< y 0<∧if

"x and y is in the origion" x 0= y 0=∧if

"Not acceptable" x 0= y∧ y 0= x 0≠∧∨if

:=

BB 1 1, ( ) "Both x and y is in the positive region"=

BB 1 1−, ( ) "x is in the positive region and y is in reganive"=

BB 1− 1, ( ) "x is in the negative region and y is in positive"=

BB 1− 1−, ( ) "Both x and y is in the positive region"=

BB 0 0, ( ) "x and y is in the origion"=

BB 0 1, ( ) "Not acceptable"= BB 1 0, ( ) "Not acceptable"= BB 0 1−, ( ) "Not acceptable"=

BB 1 1, ( ) "Both x and y is in the positive region"=

Test x y, ( )

100 y 0≥if

200 otherwise

x 0≥if

300 y 0≥if

400 otherwise

x 0<if

:=

Page 10: Mathcad - MathCad Lessons

Test 4− 2, ( ) 300=

i 1 2, 4..:= i

1

2

3

4

=

x

3

4

7−

10−

:= y

2

1−

3

2−

:=

Testi

100 "This is a comment line"

xi

0≥ yi

0≥∧

if

200 "Use this line for text"

xi

0≥ yi

0<∧

if

300 "Use this line for text"

xi

0≤ yi

0≥∧

if

400 otherwise

:=

Testi

100

200

300

400

=

Pass "Passes-Solution Works":=

Fails "Fails-Retry":=

p 1 2, 3..:= Result

5−

0

5

:=

Zero "Result is Zero":=

Tp

Pass Resultp

0>if

Fails Resultp

0<if

Zero otherwise

:= T1

"Fails-Retry"=

T2

"Result is Zero"=

T3

"Passes-Solution Works"=

Range Variable and Vectors

Page 11: Mathcad - MathCad Lessons

v stack 1 2, ( ):=

w stack 1 "a", 3, ( ):=

v1

2

=

w

1

"a"

3

=

Plotting a Range over a Log Scale

Low 0.001:= High 10000:= Intervals 20:=

Step

logHigh

Low

Intervals0.35=:= log

High

Low

7=

r 1 2, Intervals 1+( )..:=

Xr

Low 10r 1−( ) Step⋅

⋅:=

Function z( ) z:= s 0.00110000 0.001−

20, 10000..:=

s

-31·10

=

Page 12: Mathcad - MathCad Lessons

-31·10

500

999.999

31.5·10

32·10

32.5·10

33·10

33.5·10

34·10

34.5·10

35·10

35.5·10

36·10

36.5·10

37·10

...

1 104−

× 0.01 1 100 1 104

×

1 104−

×

1 103−

×

0.01

0.1

1

10

100

1 103

×

1 104

×

Function s( )

s

1 104−

× 0.01 1 100 1 104

×

1 104−

×

1 103−

×

0.01

0.1

1

10

100

1 103

×

1 104

×

Function X( )

X

Xr

-31·10

-32.239·10

-35.012·10

0.011

0.025

0.056

0.126

0.282

0.631

1.413

3.162

7.079

15.849

35.481

79.433

...

=

=

Page 13: Mathcad - MathCad Lessons

m 2kg:=

75kgf 165.347 lbf⋅=

v 200cm

s:=

65kgf 143.3 lbf⋅=

m v2

24 J⋅=

Page 14: Mathcad - MathCad Lessons
Page 15: Mathcad - MathCad Lessons
Page 16: Mathcad - MathCad Lessons

θT

24.3

26.6

:=

0.2, ) 25.68=

Page 17: Mathcad - MathCad Lessons