フィルターのクリア

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 Center および File ExchangeSignal 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