簡便なラッチ回路の構成
42 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ryo Shinohara
le 19 Août 2019
Commenté : Ryo Shinohara
le 20 Août 2019
下記のようなコードを作りました。中身は1度でも1の入力がされると、その後は1の入力が続く仕組みとなっています。
これよりも簡便な関数もしくは、simulinkのブロック図がありましたら教えて頂けないでしょうか。
よろしくお願い致します。
clear;
aa = 0 : 0.01 : 10;
u = ones(1,numel(aa));
flg = zeros(1,numel(aa));
for x = 2 : 1 : 10002
u(x) = sin(deg2rad(x / 10));
if flg(x-1) == 1
flg(x) = 1;
else % flg == 0
if u(x) == 1
flg(x) = 1;
end
end
end
hold on
plot(flg);
plot(u);
hold off
0 commentaires
Réponse acceptée
Shoumei
le 19 Août 2019
MATLABコードがあるのであれば、ラッチ回路部分はMATLAB Functionブロックに移植するのが良いと思います。
SIN波は外部から入力したとして、MATLAB Functionブロック内部のコードはこんな感じになります。
function y = fcn(u)
persistent flg
if isempty(flg)
flg = 0;
end
if flg == 1
flg = 1;
else
if u == 1
flg = 1;
end
end
y = flg;
Simulinkブロック線図で書くのであれば下図のようになります。
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with RF Blockset 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!