١ - ﺮﻣا) file name (Edit: - ﺔﺘﻔﻴﻇو ﻞﺣ 2 prog:
١ - ﺮﻣا) file name (Edit: - ﺔﺘﻔﻴﻇو ﻞﺣ 2 prog:
) (command window
-:
-
-
-: prog2
clc
clear
close all
;)'=a=input('a
;)'=b=input('b
;)x=linspace(a,b,1000
;)'=)y=input('y(x
;)plot(x,y
grid
) (file ) ( save as
) (F5 )) ( a,b,y(x ) (command window )(plot
** vector x ) ] (EX: x=[2 5 8 2 1
-: ) (x
]>>x=[2 5 8 2 1
=x
2 5 8 2 1
)>>x(2
=ans
5
** vector x ) ] (EX: x=[2 5 8 2 1
-: ) : ( x
]>>x=[2 5 8 2 1
=x
2 5 8 2 1
)>>x(2:4
=ans
2
=ans
1
** vector x ) ] (EX: x=[2 5 8 2 1
-: ][ = ) (x
]>>x=[2 5 8 2 1
=x
2 5 8 2 1
][ = )>>x(3
=ans
2 5 2 1
) Note : [] mean Not a Number ( NaN
** ) length(x
** ) size(x
Example:]>>x=[2 5 8 2 1
=x
2 5 8 2 1
) <<size(x
= ans
1
** -:
- )- : sum(x x
- ) : mean(x x
- ) : max(x x
- ) : min(x x
- ) : prod(x x
- ) : find(x= = value x
-:
] <<x=[ 2 3 8 9 4 1
=x
1
9 4
) <<sum(x
= ans
27
<<mean(x )
= ans
4.5000
<<max(x )
= ans
9
<<min(x )
= ans
1
<<prod(x )
= ans
1728
<<find(x==8 )
= ans
3
<<find(x<=3 )
= ans
1
<<find(x>=3&x<=9 )
= ans
2
<<find(x>=3|x<=9 )
= ans
1
** -: hold on \ off on
off
-: x
-:
clc
clear
close all
;)'=a=input('a
;)'=b=input('b
;)x=linspace(a,b,1000
;)'=)y=input('y(x
;)ymax=max(y
;)i=find(y= = ymax
;)ymin=min(y
;)i1=find(y= =ymin
;y1=y
;y2=y
;][=)y1(1
;][=)y2(end
;yy=y1.*y2
;)ind=find(yy<=0