%% MAE 215: Introducion to Programming in MATLAB
%% QUESTION 1
%Part a
x=5
%Part b
y=25^2
%Part c
z=(3+4i)+8^2
%Part d
k=sqrt(36+7^2)
%Part e
h=exp(72/5+6.64)
%Part f
areacircle=pi*11.21^2 %aea of a circle
%Part g
cirumference=2*pi*11.21 %circumference of a circle
%Part h
areasquare=7.81^2 %arrea of a square
%Part i
sidelength=nthroot(107.81,3) %finding side length of a cube
%Part j
mag_z=abs(z) %magnitude of a vector z
%% QUESTION 2 %%
%part a
v=[sqrt(15),13,34.7^2,sqrt(54),89.2,0.541,exp(7/8),10,log10(34.2)] %vector definition
%part b
max_v=max(v) %maximum value of the vector
min_v=min(v); %minimum value of the vector
elementmax=find(v==max(v)) %element maximum value is found
elementmin=find(v==min(v)) %%element minimum value is found
%part c
squareroot_v=sqrt(v) %squareroot of vector v
cuberoot_v=nthroot(v,3) %cuberoot of vector v
seventhroot_v=nthroot(v,7) %seventhroot of vector v
%part d
length_v=length(v) %length of vector v
no_of_elements=numel(v) %number of elements in vector v
%part e
v(find(v==max(v)))=max(v)*8.1 %replacing maximum value
v(1,6)=min(v)*8.1 %replacing the minimum value
%part f
new_vector=v([3 7 end]) %creating a new,unique vector containing 3rd,7th and last value of vector v
%part g
vector_spaced=linspace(0,10,100) %defining a vector from 0 to 10 with 100 equally spaced elements
%part h
d=[110:0.1:120] %defining a vector from 110 to 120 in steps of 0.1
length_of_d=length(d) %length of vector d
%part i
t=[0:0.1:2*3.1416] %evaluating trigonometric functions from 0 to 2(pi)
sin_of_t=sin(t)
cos_of_t=cos(t)
%part j
x=0.54
a=[1 x (x^2)/factorial(2) (x^3)/factorial(3) (x^4)/factorial(4) (x^5)/factorial(5) (x^6)/factorial(6) (x^7)/factorial(7) (x^8)/factorial(8)]
sum_of_a=sum(a) %summing enties of vector a
exponent_of_x=exp(0.54) %exponent of 0.54
%part k
r1=rand(100,1) %defining a 100 by 1, random vector r1
mean_of_r1=mean(r1) %mean of random vector r1
median_of_r1=median(r1) %median of random vector r1
mode_of_r1=mode(r1) %mode of random vector r1
%% QUESTION 3:UNDERSTANDING MATLAB MATRICES%%
%part a
A=[6 5 1;12 2 0;2 1 6] %defining vectors
B=[6 17 8]
%part b
eigen_value_of_A=eig(A) %eigenvalues of vector A
determinant_of_A=det(A) %determinant of vector A
inverse_of_A=inv(A) %inverse of vector A
%part c
A(2,1)=A(1,1) %replacing maximum values with a11 and a12
A(2,3)=A(1,2) %replacing minimum values with a11 and a12
%part d
A2=[A(2,:);A(3,:);B] %a vector from last two rows of A and vector B
%part e
sum_of_row1_of_A=sum(A(1,:)) %sum of first row of A
sum_of_column1_of_A=sum(A(:,1)) %sum of first column of A
%part f
number_of_elements_in_A=numel(A) %number of elements in A
number_of_elements_in_B=numel(B) %number of elements in B
multiply_A=7.2*A %multiplying each element in A by 7.2
multiply_B=2*B %%multiplying each element in B by 2
% �To find the product of the two vector, vector B is multiplied by vector A.
% �The product of the two vectors is accomplished by multiplication of row of vector B with column of vector A to give a 1�3 matrix.
multiply_AB=B*A %multiplying matrices A and B
%part g
X=fliplr(B) %fliping vector B from right to left
Z=transpose(X) %transposing thr resulting matrix into a column vector
new_B=flipud(Z) %fliing the resulting matrix againg from u to down
%part h
I=rand(6) %defining a random 6 by 6 matrix
O=zeros(3) %defining a random 3 by 3 matrix of zeros
P=ones(3) %defining a random 3 by 3 matrix of ones
N=eye(4) %defining a 4 by 4 identity matrix
%%combining matrix I,O and P in two steps
M=[O,P]
S=[I;M]
%part i
E=rand(8) %creating a random 8 by 8 matrix
D=E(1:4,1:4) % submatrix of E
F=E(5:8,5:8) %submatrix of E
%part j
G=[3 7 1] %defining vector G
H=[5 2 0] %defining vector H
unit_G=G/norm(G) %unit vector of G
unit_H=H/norm(H) %unit vector of H
normal_to_HandG=cross(G,H) %vector normal to G and H
dotproductofGH=dot(G,H) %dot product of the two vectors
matlabhomework.zip_The Conversion
版权申诉
186 浏览量
2022-07-15
05:29:17
上传
评论
收藏 2KB ZIP 举报
邓凌佳
- 粉丝: 65
- 资源: 1万+
最新资源
- Yolov8改进---注意力机制:Polarized Self-Attention,效果秒杀CBAM、SE.html
- 人才网站设计-asp.net+sql-(系统源码)
- asp.net+sql人才网站设计-含系统源码
- C#应用的用户配置窗体方案
- python实现绘制爱心图形的代码
- JAVAWEB项目-校园订餐系统项目源码.zip
- flink-1.19.0-bin-scala-2.12.tgz flink-1.16.3-bin-scala-2.12.tgz
- javaWeb项目-物资管理系统项目源码.zip
- javaweb项目-物流配货项目源码.zip
- 使用C++基于颜色纹理特征的人脸活体检测实现-附项目源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0