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

以下の方法でそれぞれ、アナログ入力値(参考: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)

 Réponse acceptée

horizon
horizon le 24 Avr 2019

1 vote

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

Plus de réponses (0)

Catégories

En savoir plus sur Simultaneous and Synchronized Operations dans Centre d'aide et File Exchange

Produits

Version

R2017b

Community Treasure Hunt

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

Start Hunting!