Effacer les filtres
Effacer les filtres

why do i get the error: matrix dimensions must agree ??

2 vues (au cours des 30 derniers jours)
María Jesús
María Jesús le 29 Sep 2014
Modifié(e) : Mischa Kim le 29 Sep 2014
this is what I'm trying to plot
x=linspace(0,100,100);
a=5;
y=1/(abs(a*x)+1);
figure
plot(x,y)
how do I fix this error?

Réponse acceptée

Mischa Kim
Mischa Kim le 29 Sep 2014
Modifié(e) : Mischa Kim le 29 Sep 2014
Maria, use
y = 1./(abs(a*x) + 1);
instead. Notice the dot right after the "1". This so-called elementwise division is necessary because x is a vector. See the documentation for more detail.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks 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