calculating on time of signal

11 Ansichten (letzte 30 Tage)
ALI MUAAMAR
ALI MUAAMAR am 6 Mai 2024
Beantwortet: Naren am 7 Mai 2024
i have 2 square signal with the same amplitude=5 but 2 different on time the first one stays on for 0.4 seconds and the other one for 0.6 and i need a block or a code to use in matlab function that can calculate the time and if it is =0.4 a bit 0 will be the output and if on time was 0.6 bit 1 will be the output.

Akzeptierte Antwort

Naren
Naren am 7 Mai 2024
Hello Ali,
To achieve this in MATLAB, you can create a function that analyzes the square wave signal to determine its on-time duration and then outputs the corresponding bit value based on the duration.
Refer to the following sample code, this method assumes the square signal starts with an "on" state:
onStateDuration = find(sqaureWave==0,1)-1; %no of on state samples.
inSeconds = onStateDuration/samplingRate; %convert on state duration in to seconds.
if (inSeconds == 0.4)
bitOutput = 0;
else
bitOutput = 1;
end
Make changes to the code for desired behavior.
Regards.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by