フィルターのクリア

I am getting the wrong plots for g1 and g2..help

1 回表示 (過去 30 日間)
James
James 2017 年 4 月 16 日
回答済み: GEEVARGHESE TITUS 2017 年 4 月 16 日
t = 1:500;
A = 4;B = 10;C = 2.4; D = 2;
g = sin(t/30); %Original Sin Wave
g1 = A*g.*(t+B); %1st wave transformation
g2 = C*g.*(t*D); %2nd wave transformation
plot(t,g,t,g1,t,g2);
legend('g(t) = sin(t/30)', 'g1(t) = Ag(t + B)', 'g2(t) = Cg(Dt)')
title('Wave Transformation'); % percent signs are used to comment code
xlabel('time');
ylabel('value');

回答 (2 件)

Star Strider
Star Strider 2017 年 4 月 16 日
It’s not clear what you intend.
If I interpret your legend correctly, the changed lines may be what you want.
The Code
t = 1:500;
A = 4;B = 10;C = 2.4; D = 2;
% % g = sin(t/30); %Original Sin Wave
% % g1 = A*g.*(t+B); %1st wave transformation
% % g2 = C*g.*(t*D); %2nd wave transformation
g = @(t) sin(t/30); %Original Sin Wave
g1 = A*g(t+B); %1st wave transformation
g2 = C*g(t*D); %2nd wave transformation
plot(t,g(t),t,g1,t,g2);
legend('g(t) = sin(t/30)', 'g1(t) = Ag(t + B)', 'g2(t) = Cg(Dt)')
title('Wave Transformation'); % percent signs are used to comment code
xlabel('time');
ylabel('value');
My code is a guess so If I got it wrong, experiment to get the result you want.

GEEVARGHESE TITUS
GEEVARGHESE TITUS 2017 年 4 月 16 日
What are you expecting as output? The code as such is working fine. You can view the plots using subplots to get a better view.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by