Subplot and for loop

3 ビュー (過去 30 日間)
Mark Dawson
Mark Dawson 2020 年 2 月 26 日
コメント済み: Mark Dawson 2020 年 2 月 26 日
So, I'm working on my control systems thesis, and I have an unecaseraly difficult closed lop trnsfer function.
My final task is to discuss the system robustness to a change in the damped natural frequency "wn" by adding 5% and 10% respectivelly. I need to plot the errors as a series of subplots.
In less specific examples, how could I have say a sine wave "x = sin(2*pi*f*t);" and have say a loop " for f = [10,15,20];" then have a series of three subplots for each respective frequency?
I should add having say:
x1 = sin(2*pi*f1*t)
x2 = sin(2*pi*f2*t)
x3 = sin(2*pi*f3*t)
Simply isnt an option here.
  2 件のコメント
Adam
Adam 2020 年 2 月 26 日
I don't really see a problem with just doing the obvious, something like:
f = [10, 15, 20];
t = ... % Whatever t is defined as
for n = 1:numel( f )
hAxes = subplot( 1, 3, n );
plot( hAxes, t, sin( 2 * pi * f( n ) * t ) );
end
Mark Dawson
Mark Dawson 2020 年 2 月 26 日
Trouble is my overall closed loop tf is pretty complicated, repeating it several times would be very messy. I did figure out the olbvious solutin though. Thanks anyway buddy :)

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

採用された回答

Mark Dawson
Mark Dawson 2020 年 2 月 26 日
Found my solution guys!
n=[1,2,3];
f=[10,15,20];
x(n) = sin(2*pi*f(n)*t);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSwitches and Breakers についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by