フィルターのクリア

how can i plot 5 periods of this signal

9 ビュー (過去 30 日間)
ocsse
ocsse 2018 年 3 月 24 日
編集済み: Image Analyst 2021 年 9 月 30 日
hi, i have the following signal and i want to plot 5 cycles of it. but i'm getting an error
samples = 500;
T = 5;
f0 = 1/T;
t = linspace(0,T,samples+1); % 5 cycles
t(end) = [];
s2_hinf = exp(-((t-6)/4));
s2 = repmat(s2_hinf, [1 5]);
figure(1)
plot(t, s2);
but i'm getting the following error Error using plot Vectors must be the same length.
  2 件のコメント
Jan
Jan 2018 年 3 月 25 日
編集済み: Jan 2018 年 3 月 25 日
@OMAR ALQARNI: Please do not remove the relevant part of the question. Thanks.
Did you do this, because this is a homework and you do not want it to be found? Remember that the original version is stored in e.g. Google's cache. In addition, you did not let the forum solve your homework, but showed your own effort and asked a specific question. This is not cheating. Communicating with other programmers is a useful strategy to learn programming.
Rukshi Sundararaj
Rukshi Sundararaj 2021 年 9 月 29 日
i just want to say thank you. <3 you are amazing

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

採用された回答

Jan
Jan 2018 年 3 月 24 日
編集済み: Jan 2018 年 3 月 24 日
If you use repmat to concatenate the data 5 times, you have to concatenate the time t also 5 times, but add T in each block cumulatively:
samples = 500;
T = 5;
t = linspace(0,T,samples+1); % 5 cycles
t(end) = [];
s2_hinf = exp((6 - t) / 4);
s2 = repmat(s2_hinf, [1 5]);
t2 = reshape(t(:) + (0:T:4*T), 1, []); % >= Matlab R2016b
figure;
plot(t2, s2);
With older Matlab versions:
t2 = reshape(bsxfun(@plus, t(:), 0:T:4*T), 1, []);

その他の回答 (2 件)

Image Analyst
Image Analyst 2018 年 3 月 24 日
Your linspace() is wrong. You could do this:
samples = 500;
T = 5; % Period
f0 = 1/T; % Not used!
t = linspace(0, 5 * T, samples); % 5 cycles
s2_hinf = exp(-((t-6)/4));
plot(t, s2_hinf);
But I don't see where any cycles comes in. You are not using anything like sin() or cos(), so are you expecting oscillations?

Image Analyst
Image Analyst 2018 年 3 月 24 日
Perhaps you mean this:
samples = 500;
T = 5; % Period
f0 = 1/T; % Not used!
t = linspace(0, T, samples); % 5 cycles
s2_hinf = exp(-((t-6)/4));
s5 = repmat(s2_hinf, [1, 5]);
t = linspace(0, length(s5), samples*5); % 5 cycles
plot(t, s5);
grid on;
  2 件のコメント
ocsse
ocsse 2018 年 3 月 24 日
how do you make the x axis from 0 to 25?
Image Analyst
Image Analyst 2021 年 9 月 30 日
編集済み: Image Analyst 2021 年 9 月 30 日
@ocsse, how about
t = t / 100;
or
t = linspace(0, 25, samples*5);

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

カテゴリ

Help Center および File ExchangeSignal Attributes and Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by