COMPX202 Java

Java Python NZUWI2024S_COMPX202

Assignment 3: Android Studio
(Weighting: 20%)

Due date: Friday 21
st
June 2024 at 23:59
Submission instruction: As indicated below, you must work with a Git repository and upload
your work on the university’s GitLab server. You also need to upload the final version of your
Android project to Blackboard as a ZIP file (from Android Studio, in menu
File>Export >Export to ZIP file…). The ZIP file should be named "GA3.zip" where is
your group number. The ZIP file should include a copy of your final README.md file.

Introduction

The goal in this assignment is to understand and implement an Android Studio App.

IMPORTANT: The assignment is group work. The usual rules on plagiarism fully apply: you
cannot copy answers from any other students, or copy from the internet without
acknowledgement. Cases of plagiarism will be strictly dealt with.

Part A: Creating An Android Java Project

The first stage is to create a new Android Java project. Name this project
Compx202A3_G (e.g. Compx202A3_G11). The Project will have
three activities (MainActivity, CommentActivity, and RateActivity) that are shown and
described individually below. Some of the components/widgets/UI elements are for you to
identify.

1. MainActivity

• The basic structure of MainActivity is shown in Figure 1.
• You should have your group number posted. NZUWI2024S_COMPX202
• The 3 buttons will serve as links to the remaining 3 activities.
• The 3 activities should be about sensors and use sensors discussed in the lecture Notes.

2. Sensor1Activity

• An example structure of Sensor1Activity is shown in Figure 2.
• This is just an example.

3. Sensor2Activity

• An example struc COMPX202、Java ture of Sensor1Activity is shown in Figure 3.
• This is just an example.

4. Sensor3Activity

• An example structure of Sensor1Activity is shown in Figure 4.
• This is just an example.

Figure 1 Figure 2 Figure 3 Figure 4
NZUWI2024S_COMPX202

Question/Task 1: Show the complete code for MainActivity.java.
Question/Task 2: Explain Sensor1 and show the complete code for Sensor1Activity.java.
Question/Task 3: Explain Sensor2 and show the complete code for Sensor2Activity.java.
Question/Task 4: Explain Sensor3 and show the complete code forSensor3Activity.java.
Question/Task 5: Screencap every running activity, save them as images, and add them in
the Readme file later. Add also all images in your zip file.


Part B: Uploading to GitLab

The next stage is to create a project in GitLab, which will be your remote repository. Use the
same project name from Android Studio. Commit and push all your files.

Part C: Creating README.md

This stage is to create a ‘README.md’ document which will serve as the documentation for
your GitLab repository. It will also serve as your report for this assignment.

1. In your new README file, add the following lines

Assignment 3 by *your group number* (*your ID numbers*)

2. You should see the text you just entered formatted as a heading. Leave a blank line and add
a line with “## Question 1”. Write next your answers to Question 1.
3. Do the same for the rest of the Questions (2-5).
4. Do a final check to make sure you have committed and pushed your most recent work.
Ensure that you can see your changes on GitLab.
5. Include as a zip file the final version of your README.md file and all images on
Blackboard (Assignment 3)         

### 回答1: void fft(struct compx *xin,int n) 函数的功能是对输入的复数数组进行快速傅里叶变换(FFT)。 傅里叶变换是一种数学变换,可以将信号从时域转换到频域,用于分析信号的频率成分。FFT是一种高效的算法,可以加快傅里叶变换的计算速度。 该函数的输入参数为一个指向复数结构体的指针xin和一个整数n,表示输入数组的长度。复数结构体compx定义了一个复数的实部和虚部。 函数的实现过程如下: 1. 如果n等于1,即输入数组的长度为1,则不需要做任何计算,直接返回。 2. 定义一个临时复数结构体数组,长度为n。 3. 将输入数组按照位逆序重新排列,得到新的数组,存放在临时数组中。 4. 定义一个复数变量w,其实部为1,虚部为0。 5. 对输入数组长度进行二分,依次进行迭代操作,分别得到当前划分的长度k和旋转因子Wnk。 a. 划分长度k从2开始,每次乘以2,直到k小于等于n。 b. 旋转因子Wnk是一个复数,可以通过Euler公式计算:Wnk = cos(2π/n) + jsin(2π/n),其中j为虚数单位。 6. 对划分长度k进行迭代操作,依次对同一划分的不同位置进行计算。 a. 对于划分长度k,计算步长step为n/k。 b. 从0到n-1,以步长step进行迭代,依次获取当前划分的不同位置。 c. 定义一个复数变量旋转因子W,初始值为1,用于不同位置之间的旋转。 d. 对于当前划分的每个位置,计算出它对应的旋转因子Wnk,并进行计算和交换操作。 7. 重复步骤6,直到划分长度k等于n。 8. 将计算结果从临时数组中复制回输入数组。 以上就是fft(struct compx *xin,int n)函数的功能和实现过程的简要说明。通过该函数,可以对输入的复数组进行快速傅里叶变换,得到信号的频域表示。 ### 回答2: void fft(struct compx *xin,int n) 函数的功能是对输入的复数数组进行快速傅里叶变换。 快速傅里叶变换(FFT)是一种高效算法,用于计算离散傅里叶变换(DFT)。DFT将时域信号转换为频域信号,可以用于信号处理、图像处理、通信等领域。 该函数的输入参数为一个复数结构体指针xin和一个整数n。复数结构体中通常包含两个成员,一个是实部,一个是虚部,分别用来表示一个复数的实数部分和虚数部分。 在函数体内部,需要根据输入的复数数组进行FFT计算。具体的计算步骤如下: 1. 首先将输入的复数数组按照特定规则重新排序,以便后续计算能够高效进行。 2. 利用两个循环依次计算各个频率分量的幅度和相位。这个过程中使用了蝶形算子,可以大大减少计算量。 3. 将计算得到的频域信号存储到输出的复数数组中。 4. 返回结果,完成快速傅里叶变换。 需要注意的是,该函数只实现了快速傅里叶变换的计算过程,没有进行后续的逆变换或其他操作。如果需要逆变换或其他进一步处理,可以根据具体的需求进行扩展。 总之,该函数通过在输入的复数数组上进行特定计算,实现了快速傅里叶变换的功能,将时域信号转换为频域信号,为信号处理和相关领域的应用提供了基础计算能力。 ### 回答3: 快速傅里叶变换(FFT)是一种用于将离散时间信号转换为频域信号的算法。给定一个由复数构成的数组xin和数组长度n,函数fft将对xin进行FFT变换。 函数的输入参数为一个指向compx结构体的指针xin,它表示输入的复数组。compx结构体包含两个成员变量,一个是实部成员变量xreal,另一个是虚部成员变量ximag。 函数的第二个输入参数n表示数组的长度,即需要进行FFT变换的数据点的数量。 函数的功能是对输入的复数组进行快速傅里叶变换。快速傅里叶变换是一种高效的算法,它可以在O(nlogn)的时间复杂度内完成计算。该算法将复杂度较高的傅里叶变换过程分解为多个较为简单的计算步骤,从而加快了计算速度。 在函数体内部,会通过递归的方式将输入数组分成两部分,并对分解后的数组进行递归调用。递归的终止条件是数组长度n等于1的情况,即每个数组只包含一个数据点时,无需再进行分解。 在递归调用过程中,会根据当前数组长度n计算出频域中的频率分量,然后通过运算得到该频率分量对应的复数结果。最后,将分解后的结果合并为最终的FFT结果。 函数的返回类型为void,表示不返回任何结果,而是直接在输入的数组中进行原地修改。因此,函数调用后,输入数组xin中的数据将被修改为对应的FFT变换结果。 通过调用该函数,我们可以方便地将一个复数数组转换为频域信号,从而可以进行频域上的各种分析和处理操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值