help!!! with plot

2 vues (au cours des 30 derniers jours)
Qiandong Dong
Qiandong Dong le 24 Déc 2019
Réponse apportée : KSSV le 24 Déc 2019
clear all
a=200;b=5;cm=10;cr=3;v=600;k=6;u=0.1;s=0.2;e=2;cp=2;t=1;
pr=1:10;
r=-(pr*u*(b*cm - a + cp*e*k + b*cp*e*t))/(8*v + 2*b*pr.^2*u - 2*b*cm*pr*u + 2*b*cr*pr*u - 2*b*pr.^2*s*u);
plot(r)
Why just plot a point, not a line?

Réponse acceptée

Image Analyst
Image Analyst le 24 Déc 2019
Modifié(e) : Image Analyst le 24 Déc 2019
Because you used slash (matrix division) instead of dot slash (element-by-element division). Try it this way:
clear all
a=200;
b=5;
cm=10;
cr=3;
v=600;
k=6;
u=0.1;
s=0.2;
e=2;
cp=2;
t=1;
pr=1:10;
r=-(pr*u*(b*cm - a + cp*e*k + b*cp*e*t)) ./ (8*v + 2*b*pr.^2*u - 2*b*cm*pr*u + 2*b*cr*pr*u - 2*b*pr.^2*s*u);
plot(r, 'bs-', 'LineWidth', 2)
grid on;

Plus de réponses (2)

Bhaskar R
Bhaskar R le 24 Déc 2019
MATLAB operator "/" performs linear equation solver, apply dot elemetwise(./) division
clear;
a=200;b=5;cm=10;cr=3;v=600;k=6;u=0.1;s=0.2;e=2;cp=2;t=1;
pr=1:10;
r=-(pr*u*(b*cm - a + cp*e*k + b*cp*e*t))./(8*v + 2*b*pr.^2*u - 2*b*cm*pr*u + 2*b*cr*pr*u - 2*b*pr.^2*s*u);
plot(r)

KSSV
KSSV le 24 Déc 2019
a=200;b=5;cm=10;cr=3;v=600;k=6;u=0.1;s=0.2;e=2;cp=2;t=1;
pr=1:10;
r=-(pr*u*(b*cm - a + cp*e*k + b*cp*e*t))./(8*v + 2*b*pr.^2*u - 2*b*cm*pr*u + 2*b*cr*pr*u - 2*b*pr.^2*s*u);
plot(r)
Element by element divison is needed.
/ is replaced with ./.

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