MATLAB中的数据获取而无需编写代码
可以在MATLAB中执行常见的数据采集任务®without writing code. The Analog Input Recorder app allows you to acquire analog voltage, current, or audio data from supported devices. The Signal Analyzer app provides visualization and signal analysis capabilities. And you can output analog data using the Analog Output Generator app.
这些应用程序中的每一个都允许您执行任务,然后自动为该任务生成等效的MATLAB代码,以便您可以轻松地配置环境并在将来再次执行相同的分析。
In this video, these steps are demonstrated using audio data as an example. Audio is recorded into MATLAB from a microphone, a low-pass filter is applied, and the resulting signal is generated on a speaker. The automatically generated MATLAB code is then assembled in a single MATLAB script that can run the whole workflow.
数据采集工具箱™包含模拟输入记录器和模拟输出生成器应用程序。信号分析仪应用程序包含在信号处理工具箱™中。
In this video, I’ll show how you can acquire, analyze, and generate analog signals in MATLAB without writing code. To do this, you can use interactive apps in MATLAB.
要获取数据,您可以使用数据采集工具箱中的模拟输入记录器。该应用程序允许您从支持的DAQ设备和音频设备的音频信号中获取模拟电压信号。金宝app我将从耳机麦克风中获取音频数据。在我吹口哨时,让我们记录五秒钟的数据。
As you can see, this is recorded to the MATLAB workspace. Here it is in a timetable, which is nice because this single variable contains the timing information and the data. I can select the data and plot it in MATLAB. And if I zoom in, I can see that this audio data has a sinusoidal behavior.
现在,如果我想在将来以相同的方式执行相同的收购,我可以生成一个脚本。该脚本为我提供了等效的MATLAB代码,以便将来执行相同的步骤。让我们保存脚本。
现在我已经获得了一些数据,如果我想分析它怎么办?我可以从信号处理工具箱中使用Signal Analyzer应用程序。这个应用程序为我提供了许多我可以使用存储的数据来处理的事情DAQ_1timetable. I can visualize it in the time domain, but I can also look at it in the frequency domain or in a time-frequency plot. If I zoom into this region where I have the strongest frequencies, I can clearly see in the time-frequency plot those notes that I whistled.
In addition to visualizing data, I can also perform analysis like a low-pass filter. Let’s say I want to remove some of these higher frequencies. I can set a passband frequency of 1 kHz and bump up the steepness. As you can see, some of these higher frequencies are cut out and some of those higher notes that I whistled are no longer visible here.
From this app, I can export this new data into MATLAB, and I can also generate a function. You can see here that this function gives me the MATLAB code for creating that same low-pass filter with 1000 Hz passband frequency and a steepness of 0.9999. Let’s save this function.
我已经获得了数据。我已经进行了一些分析。我也可以输出数据。我们可以从数据采集工具箱中使用模拟输出生成器应用。我会将音频数据输出到计算机的音栏中。为了进行比较,我将首先输出我们最初记录的数据DAQ_1variable. Now let’s listen to the data that we analyzed with that low-pass filter inDAQ_1_CH1。
和以前一样,我可以生成一个脚本来执行这些步骤。这再次为我提供了MATLAB代码版本,以执行相同的配置和信号生成。
Now I’ve generated the equivalent MATLAB code for each of these three steps. How do I tie them all together in a single workflow? Well, I’ve created this script template here, and I can take that automatically generated code and add it in. The code for AcquireAudio, GenerateAudio, and for the preprocessing step, we have a function with this signature. But instead of preprocessingx和tx, we preprocess the data that we acquired in this acquire audio step:数据和时间段。And this function gives us a variabley。So when we generate audio, instead of generatingDAQ_1_CH1.CH1,我们将生成数据y。因此,让我们一起运行。
That’s how you can acquire, analyze, and generate analog data in MATLAB without writing code. Thank you.
Related Products
Featured Product
数据采集工具箱
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)