アナログ入力の値をプ​ロットしてそのグラフ​の最大振幅を求める方​法が知りたい

3 次查看(过去 30 天)
horizon
horizon 2019-4-24
回答: horizon 2019-4-24
以下の方法でそれぞれ、アナログ入力値(参考:Acquire Data Using NI Devices)とグラフの最大振幅(参考:どうすれば最大振幅値を求められますか)を求めることはできています。
しかし、これらを組み合わせたプログラムではエラーが出てしまい、どのように修正すれば良いかわかりません。
エラー内容
構造体の内容が非構造体配列オブジェクトから参照されています。
エラー:programname(line 13)
disp(time.data)
組み合わせたプログラム
s = daq.createSession('ni');
ch = addAnalogInputChannel(s,'Dev1', 'ai1', 'Voltage');
s.Rate = 8000;
data = s.inputSingleScan;
disp(data)
s.DurationInSeconds = 2;
[data,time] = s.startForeground;
plot(time,data);
disp(time.data);
xlabel('Time (secs)');
ylabel('Voltage')
[up,lo] = envelope(time.data,300);
maxAmplitude = peak2peak(up-lo);
disp(maxAmplitude)
アナログ入力値をプロットするプログラム
s = daq.createSession('ni');
ch = addAnalogInputChannel(s,'Dev1', 'ai1', 'Voltage');
s.Rate = 8000;
data = s.inputSingleScan;
disp(data)
s.DurationInSeconds = 2;
[data,time] = s.startForeground;
plot(time,data);
disp(time.data);
xlabel('Time (secs)');
ylabel('Voltage')
グラフの最大振幅を求めるプログラム
load sensorData
t = 0:1/1000:3;
s1 = chirp(t,30,2,5).*exp(-(2*t-3).^2)+2;
t1 = (0:length(s1)-1)/Fs;
subplot(2,1,1)
plot(t1,s1)
title('s_1')
[up,lo] = envelope(s1,300);
maxAmplitude = peak2peak(up-lo);
disp(maxAmplitude)

采纳的回答

horizon
horizon 2019-4-24
line13、14を以下のようにコメントアウトしたところ、エラーはなくなりました。
%disp(time);
%disp(data);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simultaneous and Synchronized Operations 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!