0% found this document useful (0 votes)
44 views

١ - ﺮﻣا) file name (Edit: - ﺔﺘﻔﻴﻇو ﻞﺣ 2 prog:

This document discusses various commands and functions in MATLAB for manipulating and accessing elements in vectors. Some key points covered include: - The 'edit' command is used to open a previously saved file or create a new file if one is not saved. - To access specific elements in a vector, the element number is written in parentheses after the vector name (e.g. x(2)). - Functions like length(), end, and size() can be used to determine properties of a vector like its length, last element, or number of rows and columns. - Elements can be added, removed, or replaced using indexing and assignment operations. - Common functions discussed include sum(), mean(), max

Uploaded by

Mohamed Ashraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

١ - ﺮﻣا) file name (Edit: - ﺔﺘﻔﻴﻇو ﻞﺣ 2 prog:

This document discusses various commands and functions in MATLAB for manipulating and accessing elements in vectors. Some key points covered include: - The 'edit' command is used to open a previously saved file or create a new file if one is not saved. - To access specific elements in a vector, the element number is written in parentheses after the vector name (e.g. x(2)). - Functions like length(), end, and size() can be used to determine properties of a vector like its length, last element, or number of rows and columns. - Elements can be added, removed, or replaced using indexing and assignment operations. - Common functions discussed include sum(), mean(), max

Uploaded by

Mohamed Ashraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

- )-: Edit (file name

) (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

** vector x ) ] (EX: x=[2 5 8 2 1


-: )) x(length(x )x(end
]>>x=[2 5 8 2 1
=x
2 5 8 2 1
))>>x(length(x
=ans
1
)>>x(end
=ans
1
** vector x ) ] (EX: x=[2 5 8 2 1
-: ) x(length(x)-1)x(end-1
]>>x=[2 5 8 2 1
=x
2 5 8 2 1
)>>x(length(x)-1
=ans
2
)>>x(end-1
=ans
2
** vector x ) ] (EX: x=[2 5 8 2 1
-: )x(end+1)=x(end
]>>x=[2 5 8 2 1
=x
2 5 8 2 1
)>> x(end+1)=x(end

=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

You might also like