For Loop using two variables and plotting

1 回表示 (過去 30 日間)
Osman
Osman 2014 年 9 月 21 日
回答済み: Andrei Bobrov 2014 年 9 月 21 日
Im pretty new to matlab, the question is Plot sα(t) = (e^(−2))(e^(−αt))* cos(4πt)u(t) for α ∈ {1, 3, 5, 7} in one figure for t = [0 : 0.01 : 4].
this is the code i have written, but it doesnt seem right.
g = inline ('exp(-2*t).*cos(4*pi*t).*(t>=0)','t');
for a=[1:2:7], s= inline ('exp(-a)','a'); end
t= [0:0.01:4]; figure; plot(t,g(t).*s);

採用された回答

Andrei Bobrov
Andrei Bobrov 2014 年 9 月 21 日
g = @(t,a)exp(-2*t).*cos(4*pi*t).*(t>=0)*exp(-a);
t= (0:0.01:4)';
a=(1:2:7);
y = bsxfun(g,t,a);
figure; plot(t,y);

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by