필터 지우기
필터 지우기

How to change a parameter while the signal is running?

조회 수: 1 (최근 30일)
Ali Albaidhani
Ali Albaidhani 2022년 4월 4일
Hello everyone,
I want to generate a signal that can be changed while running. I want to be able to change the magnitude while the signal is running. I tried generating a signal in background and i wrote different values for the magnitude in the command box but it didn't change anything.
I have the following code:-
%-------------------------------------
clearvars
clc
d = daqlist("ni");
deviceInfo = d{1, "DeviceInfo"};
dq = daq("ni");
fidData = fopen("logData.bin","w");
fidTime = fopen("logTime.bin","w");
DisplayTime=1;
s = daq.createSession('ni');
s.Rate=5000;
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
addAnalogOutputChannel(s,'Dev2','ao0','Voltage');
Fs=s.Rate
t1=100;
t = 0 :1/Fs : t1-1/Fs;
A=0.5;
data0 = A*sin(2*pi*t*159.2)';
b=repmat(data0,5,1);
queueOutputData(s,b);
datagiver = addlistener(s, 'DataRequired',@(src,event)...
src.queueOutputData(b));
figure(1)
clf
startBackground(s);
%%
s.stop
fclose(fidData);
fclose(fidTime);
%-------------------------------------
Please help if you have an idea. I need to do this because im making a controller for the magnitude value.
Regards
Ali

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by