Generate Signal continously and change its values while the signal is running
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!