필터 지우기
필터 지우기

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

조회 수: 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!