Error using * Inner matrix dimensions must agree.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
David Young
el 4 de Mzo. de 2015
As you can see, your code is very hard to read. You can fix this by editing it and using the "{} Code" button.
Respuestas (1)
David Young
el 4 de Mzo. de 2015
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 comentarios
David Young
el 4 de Mzo. de 2015
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.
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!