# Why do I get Matrix dimensions must agree? I am trying to plot the frequency response of this function.

1 vue (au cours des 30 derniers jours)
Eliot Flores-Portillo le 26 Avr 2021
clear all; close all; clc;
%Problem 1:
w = linspace(-pi, pi,2001);
X = (1/(1-exp(-j.*w)))*(sin(1.5.*(w))./sin(w./2))+5*pi*dirac(w);
%Frequency Domain Plot
plot(w, X);
Error using /
Matrix dimensions must agree. (line 4).
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Clayton Gotberg le 26 Avr 2021
Modifié(e) : Clayton Gotberg le 26 Avr 2021
X = (1/(1-exp(-j.*w)))*(sin(1.5.*(w))./sin(w./2))+5*pi*dirac(w);
% ^
When MATLAB sees a scalar being divided by a matrix, it doesn't make the assumption that you want to perform the operation element-wise, like it does when you multiply a scalar and matrix or when you divide a matrix by a scalar.
x = [4 2];
y = 1/x; % Error because 1/[4 2] isn't interpretable as a matrix operation.
y = 1./x; % Returns [0.25 0.5]
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Eliot Flores-Portillo le 26 Avr 2021
Oh ok thank!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Annotations dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by