필터 지우기
필터 지우기

Generate Signal continously and change its values while the signal is running

조회 수: 1 (최근 30일)
Ali Albaidhani
Ali Albaidhani 2022년 6월 27일
편집: Voss 2022년 6월 27일
Hello Everyone,
I'm trying to create a signal that runs continously in background and i want to be able to change the Magnitude of the signal from the command window (or in code) while the signal is running.
I have written a code that generates a signal in background but i can't change it's parameters while it running. I will post the code here :-
%%
dq = daq("ni");
fidData = fopen("logData.bin","w");
fidTime = fopen("logTime.bin","w");
DisplayTime=1;
s = daq.createSession('ni');
ch1=addAnalogOutputChannel(s,'Dev2','ao0','Voltage');
ch2=addAnalogInputChannel(s,'Dev2','ai10','Voltage');
ch3=addAnalogInputChannel(s,'Dev2','ai11','Voltage');
lh = addlistener(s,'DataAvailable',@plotData);
lh1 = addlistener(s,'DataAvailable',@(src, event)logData(src, event, fidData,fidTime));
s.IsContinuous=true;
s.NotifyWhenDataAvailableExceeds=floor(DisplayTime*s.Rate);
%Output
f=159.2;
Fs=40*f;
s.Rate=Fs;
t1=1;
n=round(f*t1);
T=1/f;
t = 0 :1/Fs : n*T;
A=0.1;
D = A*sinpi(2*t*f)';
D=D(2:end);
b=repmat(D,3,1);
b=[0;b];
queueOutputData(s,b);
datagiver = addlistener(s, 'DataRequired',@(src,event)...
src.queueOutputData(b));
figure(1)
clf
startBackground(s);
pause
%%
Regards,
Ali Al-Baidhani

답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Generation, Manipulation, and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by