I have to create a square wave signal on simulink where any logical value, high or low, must last for a given time. Logical values and times are sent by other simulink blocks.

조회 수: 2 (최근 30일)
I need a simulink block with two input end one output.
The first input is a vector of logic value ( e.g. V = ( 1 0 1)).
The second input is a vector of times ( e.g. T = ( t1 t2 t3)).
The vector V and T are made in other simulink blocks and each elements of V and T change continuously in the time.
The vectors are the same size.
The output must be a square wave where to each element of V correspond the same element of T. Look at the picture to understand better.
The square wave output must be a signal that I need to drive a switch.
Thanks.

답변 (1개)

Davide Masiello
Davide Masiello 2022년 5월 5일
편집: Davide Masiello 2022년 5월 5일
Maybe something like this?
clear,clc
T = [3,6,2,1,4,3,8];
V = [1,0,1,0,1,0,1];
% Block
t = cumsum(T);
t = [0,repelem(t(1:end-1),2),t(end)];
v = repelem(V,2);
plot(t,v)
axis([-inf +inf -0.5 +1.5])
  댓글 수: 3

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by