Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Ali Albaidhani
Ali Albaidhani le 27 Juin 2022
Modifié(e) : Voss le 27 Juin 2022
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

Réponses (0)

Catégories

En savoir plus sur Signal Generation, Manipulation, and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by