MATLAB Answers

Create pulses with brackets

2 ビュー (過去 30 日間)
Uerm
Uerm 2019 年 2 月 27 日
回答済み: Walter Roberson 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.

  0 件のコメント

サインインしてコメントする。

回答 (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()

  0 件のコメント

サインインしてコメントする。

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by