Create pulses with brackets

3 次查看(过去 30 天)
Uerm
Uerm 2019-2-27
Hi,
How can I create a pulse function with brackets in MATLAB. I have tried the following, but it obviously just gives 6 different points and thus not pulses.
tSpan = [0 62.5 125 125+62.5 250 300];
gluu = [2e-3 5 2e-3 5 2e-3 5];
The idea is that from time 0 to 62.5, the parameter should have the value 2e-3. From 62.5 to 125 it should be 5. From 125 to 187.5 it should be 2e-3 and so on.

回答(1 个)

Walter Roberson
Walter Roberson 2019-2-27
You have four choices:
  1. Decide on a sampling frequency and generate an output vector in which each value is repeated the appropriate number of times. repelem() can help.
  2. Use the data to generate an anonymous function that does conditional tests on the input time to decide what the output should be
  3. Use the data to generate an anonymous function that uses heaviside() to calculate the output given times
  4. Use the symbolic toolbox piecewise() to create a symbolic expression or function to calculate the output given times. Note that matlabFunction() to return anonymous functions cannot handle piecewise() constructs but that matlabFunction with the 'file' output can handle piecewise() but cannot handle vectors of times together with piecewise()

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by