フィルターのクリア

Error using plot: Vectors must be the same length.

1 回表示 (過去 30 日間)
Yasmine Sellwood
Yasmine Sellwood 2020 年 8 月 21 日
回答済み: KSSV 2020 年 8 月 21 日
Can someone please help? I've generated a plot for Signal3, but I also need to plot a single period from Signal3 (which I've named additive_noise_first) with an appropriate time vector (which I've named tPeriod).
s3 = zeros(1, period);
s3(SinglePeriod >= 0 & SinglePeriod < 2.5) = ((A*SinglePeriod(SinglePeriod >= 0 & SinglePeriod < 2.5))/4);
s3(SinglePeriod >= 2.5 & SinglePeriod < 5) = (((-A*SinglePeriod(SinglePeriod >= 2.5 & SinglePeriod < 5))+(5*A))/4);
Signal3 = repmat(s3, [1 period]); %signal 3
subplot(3,1,3)
plot(t, Signal3, 'r')
title('Signal 3')
xlabel('Time (s)')
ylabel('Amplitude')
hold off
%% 2.0 Generate the noise waveforms
tPeriod = linspace (0, 1, sample+1); %single period
tPeriod(end) = []; %
additive_noise_first = repmat(Signal3, 1, period);
plot(tPeriod, additive_noise_first, 'r');
But I'm getting this error shown below.
Error using plot
Vectors must be the same length.
Error in mission (line 82)
plot(tPeriod, additive_noise_first, 'r');

回答 (1 件)

KSSV
KSSV 2020 年 8 月 21 日
%% 2.0 Generate the noise waveforms
additive_noise_first = repmat(Signal3, 1, period); % assumoing this to be column/ array
tPeriod = linspace (0, 1,length(additive_noise_first)); %single period
plot(tPeriod, additive_noise_first, 'r');

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by