Piecewise function with function input?

3 ビュー (過去 30 日間)
Jose Sarmento
Jose Sarmento 2020 年 4 月 27 日
コメント済み: Star Strider 2020 年 4 月 28 日
Hello, I'm trying something really simple but I can't seem to make it work on matlab. There's these functions:
kHz,
V , and
s.
I want to plot and between 0 and 2 ms. I've tried piecewise, using functions, syms, but I just can't never seem to make it work. Suggestions?

採用された回答

Star Strider
Star Strider 2020 年 4 月 28 日
I hope this is not homework. If it is, you cannot ethically use this solution.
Break it up into its component functions, then use logical indexing for the threshold condition:
f = 1E+3;
vr = 0.72;
tau = 1;
vi = @(t) sin(2*pi*f*t);
vd = @(t,vr) (1-vi(t)).*(vi(t)>vr);
vo = @(t) vd(t,vr).*exp(-t/tau);
t = linspace(0, 2, 150)*1E-3;
figure
plot(t, vi(t), t, vo(t))
grid
That ran without error. Check it to be certain it matches the functions.
  4 件のコメント
Jose Sarmento
Jose Sarmento 2020 年 4 月 28 日
That made a lot of sense, thank you so much!
Star Strider
Star Strider 2020 年 4 月 28 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by