练习测试

点击here对于完成练习问题所需的数据和代码文件。

  1. 提供的文本文件(readings.txt)包含一个时间戳记,分为年,每月,每日,小时,分钟,第二和时区组件,以及传感器的读数。编写一个脚本,该脚本使用该脚本读取文件中的数据textscan功能。

    脚本必须:
    • 将时间戳转换为存储在名称的变量中的单个数字序列日期编号日期
    • 通过不将其读取到工作空间来忽略时间戳的时区组件
    • Place numeric values for the readings in a single array of type双倍的具有可变名称的读数
  2. the provided data file (ViewData。mat) contains a 19-by-3 matrixViewData使用以下列:
    1. 视频长度- 视频中的长度为几分钟
    2. 视图- 视频已观看的次数
    3. 分钟看着- 观众观看视频的总时间
    Write a MATLAB script to analyze the data to determine the effect of video length on viewer retention with the following steps:
    • Load the saved viewership data into the MATLAB workspace.
    • 创建列矢量ViewPCT按照公式:查看百分比=(观察分钟 /视图) /(视频长度),包含每个变量查看的百分比。
    • Create vectors containing the percentage viewed for short (Video length < 1.5), medium (1.5 <= Video length <= 2.25), and long (Video length > 2.25) videos).
    • 计算上一个步骤中向量中包含的值的平均值,并将结果存储在变量中shortPct,,,,MEDPCT,,,,andlongpct分别。
  3. the provided data file (tData.mat)包含气象站实例报告的温度数据。数据文件的内容是:
    1. the x-coordinates of the weather station locations (in km) stored in the column vectorX
    2. 气象站位置(以公里为单位)存储在圆柱矢量中的Y坐标(以公里为单位)y
    3. the temperature data corresponding to the station locations (in degrees C) stored in the column vectort

    编写一个MATLAB脚本以加载文件中的数据,并产生与温度站相似的轮廓图。使用Griddata功能'v4'as the interpolation method to estimate the temperatures for the x-y spatial grid points.

    该图必须包含:
    • contours spanning -5 degrees C to 5 degrees C in 1 degree increments
    • 对应于0
    • labels for the contours with theclabel function
    • 气象站位置的标记
  4. 创建一个匿名函数Fwhich accepts a (possibly vector valued) numeric input and returns a (possibly vector valued) numeric output according to the mathematical formula f(x) = x^2 - sin(x). Use this function along with thefminsearchFunction to find the local minimum value near the initial value nearx0 = 0.5。将局部最小化值和相应函数值存储在变量中XminandYmin分别。
  5. 一个调用的函数看图接受图像和可变数量的参数名称/值对,如函数标题中所示:

    功能视图(i,varargin)

    Write the validation code in the body of the function to produce an error message explaining the violation if any of the following conditions on the input arguments are not met:
    • 如果存在可变输入选项,则必须成对存在
    • the names portion of the variable input must occur before the corresponding value. Names must be strings of the value'zoom',,,,'rotate', 或者'倾斜'
    • 变量输入的值部分必须是数字

    不要编写除执行验证所需的代码之外的任何实现。

  6. the provided script(diceSimulation.m)runs a simulation of rolling six, 6-sided dice and calculating the sum. The simulation is repeated 1,000,000 times to create a histogram of the probability distribution as shown below.

    该代码产生正确的结果,但可以改进以更快地运行。重写脚本以使模拟通过1,000,000个试验,创建结果的直方图以及更快的执行时间产生相同的结果。

    the figure illustrates on result from running the script. Solutions should have a similar distribution.

  7. the provided script(LoadData.m)loads data from an impact simulation, and uses thePlotyyFunction to plot position on the left y-axis and velocity on the right y-axis. Using the outputs from thePlotyy功能,修改图以使其看起来如下图所示。
    the figure must contain:
    • an x-axis with a minimum value of 0 and a maximum value of 4
    • 位置向量作为实心蓝线的图
    • 左y轴蓝色,最小值为-5,最大值为5
    • a plot of the velocity vector as a dashed black line
    • 右Y轴为黑色,最小值为-0.5,最大值为+0.5
    • 右Y轴为黑色,最小值为-0.5,最大值为+0.5
    • 如图所示,标题读取“影响数据”
    • 每个图上有正确标签的轴上中心的图例
  8. 提供的图形应用程序(请参阅下面的屏幕截图)根据提供的方程式绘制了基于提供的幅度和频率的正弦波y= amplitude*sin(2*pi*frequency*x)on the interval defined by[0 2*pi].
    为滑块控件编写回调函数以更新图。回调必须:
    • 用新的幅度或频率更新图
    • 更新幅度和频率值的显示(标签名称EdtamplitudeandedtFrequency分别。

    Additionally, display a plot with the default values for amplitude and frequency upon starting the application.