如何用NI和MATLAB实现跟踪系统的设计

1.用输出1通道输出一个正弦信号,用采集1通道采集。然后用2通道来跟踪这个信号,也是用2通道采集。
2.更进一步的还需要一个闭环控制系的跟踪系统。就是有一个参考信号,比如说一个正弦信号,但是AO1持续给定一个0.5倍的这个正弦信号输入,需要通过AI1通道采集到的信号对AO1通道的输出值进行调制,使得采集到的信号能跟踪参考信号。
想要实现1和2,目前在尝试1,但是通道1显示缓冲区有问题
代码如下:
clear;
clc;
dq = daq("ni");
dq.Rate = 8000;
addinput(dq,"Dev1","ai0","Voltage");
addoutput(dq,"Dev1","ao0","Voltage");

output = sin(linspace(0,2*pi,1000)');
plot(output);
title("Output Data");

data1 = readwrite(dq, output);
plot(data1.Time, data1.Variables);
ylabel("Voltage (V)")
title("Acquired Signal");

data2 = readwrite(dq,[output; output]);
plot(data2.Time, data2.Variables);
ylabel("Voltage (V)")
title("Acquired Signal");
报错如下:
错误使用 work1 (第 12 行)
Generation cannot be started because the output buffer is empty.
Write data before starting a buffered generation. The following actions can empty the buffer: changing the size of the buffer, unreserving a task, setting the
Regeneration Mode property, changing the Sample Mode, or configuring retriggering.
想请教一下怎么解决以及后续的一些思路

你用的什么版本的