Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Best way to time different signals

1 回表示 (過去 30 日間)
Matthias Bach
Matthias Bach 2015 年 6 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hey everyone, I'm a beginner so pleace be forgiving ;-)
What is the best way to time different signals? Let's say, I have an output that should be constant 1000 as long as my value X*Y (fed back values) is smaller than Z. If the product becomes larger than Z, I want the product as my output. And after 3 seconds, the output should be 0. What would be the appropriate way to do this?
I have googled for quite some time now but I can't get it to work. I managed the first part but probably not in a way it should be done...
Appreciate any input! Thank you!
  2 件のコメント
Jan
Jan 2015 年 6 月 2 日
The question is not clear.
Matthias Bach
Matthias Bach 2015 年 6 月 13 日
Hey, I'll try to elaborate and maybe make it a little bit more abstract. Basically, I have one single output and I want the output to be 1000 unless a specific condition (X*Y<Z) is met. If the condition is met, the output should be Z, and after a time of 3 seconds has elapsed the output should be 0.
Does that make sense?

回答 (1 件)

Christiaan
Christiaan 2015 年 6 月 3 日
Dear Mathias,
I hope this piece of code can help you on your way. You may have a look at it.
The only point where you would have to modify the code, is for the case the time step is smaller or larger then one.
clc;clear;close all
t = linspace(0,800,800);
dt = t(2)-t(1);
x = t;
y = sin(t/10);
treshold = 5;
for i=1:length(t)
xy(i) = x(i)*y(i);
if xy(i)>treshold
state(i)=1;
else
state(i) = 0;
end
if dt*i>10
if sum(state(i-2:i))==3
xy(i) = 0;
state(i)=0;
end
end
end
subplot(3,1,1);
plot(t,state);
subplot(3,1,2);
plot(t,x.*y)
subplot(3,1,3);
plot(t,xy)
grid on
Good luck! Christiaan
  1 件のコメント
Matthias Bach
Matthias Bach 2015 年 8 月 7 日
Hi Christiaan, thanks for your reply. This seems to do what I described but I need the whole thing in Smulink.
I have attached my current solution which unfortunateky is flawed.
With this, my output equals the incoming signal S. Then when V (variable which starts at 0) becomes bigger than X, S is subtracted from itself and the output becomes 0.
However, at a certan point V drops again and becomes lower than X. With my setup, the output then equals S. This is what I need to avoid.
V starts at 0 and rises -> output=S
V passes X -> output=0
V drops and becomes lower than X -> output=0 (currently output=S)
Thanks for everyone's support!

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by