フィルターのクリア

Error using * Inner matrix dimensions must agree.

1 回表示 (過去 30 日間)
misbah 0332
misbah 0332 2015 年 3 月 4 日
コメント済み: David Young 2015 年 3 月 4 日
close all;
clear all;
clc;
%x(n) = u(n) – u(n – 6)
n1 = -1:1:6; %range of x-axis
x1 = [zeros(1,1), ones(1,6),zeros(1,1)]; %signal at y-axis
subplot(3,1,1); %subplot location
stem(n1,x1); %discreet plot
xlabel('time'); %labeling
ylabel('Amplitude'); %labeling
title('x(n) = u(n) – u(n – 6)'); %labeling
%h(n) = 2^n {u(n) – u(n – 3)
n2 = -1:1:3; %range of x-axis
x2 = [zeros(1,1),ones(1,3),zeros(1,1)]; %signal at y-axis
x2 = (2.^n2).*x2; %signal at y-axis
subplot(3,1,2); %subplot location
stem(n2,x2); %discreet plot
xlabel('time'); %labeling
ylabel('Amplitude'); %labeling
title('h(n) = 2^n {u(n) – u(n – 3)'); %labeling
x1k = fft(x1);
x2k = fft(x2);
y = x1k * x2k;
y2 = ifft(y);
subplot(3,1,3);
stem(y2);
  2 件のコメント
David Young
David Young 2015 年 3 月 4 日
As you can see, your code is very hard to read. You can fix this by editing it and using the "{} Code" button.
David Young
David Young 2015 年 3 月 4 日
I think per isakson has done it for you.

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

回答 (1 件)

David Young
David Young 2015 年 3 月 4 日
It's likely that this line
y = x1k * x2k;
should be
y = x1k .* x2k;
The * operator does matrix multiplication, but .* does array multiplication which is probably what you need here.
  2 件のコメント
misbah 0332
misbah 0332 2015 年 3 月 4 日
same error :(
David Young
David Young 2015 年 3 月 4 日
Then I guess you need to give more information. That's the only occurrence of * in the code you have shown, so the error must be elsewhere. Please can you give the full error message, and say which line of code produces it.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by