필터 지우기
필터 지우기

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 CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by