help!!! with plot
2 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Image Analyst
on 24 Dec 2019
Edited: Image Analyst
on 24 Dec 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;
0 Comments
More Answers (2)
Bhaskar R
on 24 Dec 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)
0 Comments
KSSV
on 24 Dec 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 ./.
0 Comments
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!