Error using * Inner matrix dimensions must agree.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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.
답변 (1개)
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
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 Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!