Effacer les filtres
Effacer les filtres

Plotting Error (Very Simple Code)

1 vue (au cours des 30 derniers jours)
onsagerian
onsagerian le 3 Fév 2018
Modifié(e) : onsagerian le 3 Fév 2018
As part of practice of plotting, I made a very simple code, but it has an error. Would you check the code and explain on the problem so that I can make an correction?
x=1.0:0.2:2.0; y=2/x; plot(x,y)
Error using / Matrix dimensions must agree.
Error in Untitled6 (line 2) y=2/x;

Réponse acceptée

Walter Roberson
Walter Roberson le 3 Fév 2018
y = 2./x;
The operation A/B is like A * inv(B) where * is algebraic matrix multiplication. You want element-by-element division, which is the ./ operator
  1 commentaire
onsagerian
onsagerian le 3 Fév 2018
Modifié(e) : onsagerian le 3 Fév 2018
It works! Thank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots 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