Mat lab is only plotting one point for a linspace plot
Show older comments
The code should produce a plot of anon linear curve and I cannot figure out why its only plotting one point. Any help would be appreciated
syms r k t;
p1=1;
t1=1;
v1=(r^(1/k));
p2=((r^(1/k))/(t*(r^k)^(k-1)))^k;
t2=((r^(1/k))/(t*(r^k)^(k-1)))^(k-1);
v2=1
p3=r;
t3=t;
v3=1;
p4=1;
t4=t*(r^k)^(k-1);
v4=r^(1/k);
W=((t3-t2)/(k*t1))-((t4+t1)/t1)
diffR=diff(W,r)
nth=1-((t4-t1)/(k*(t3-t2))) %L was extracted from the solution to nth in the output script
syms off
t=4
k=1.4
r=linspace(10,200)
L=1 - (t*(r.^k).^(k - 1) - 1)/(k*(t - ((r.^(1/k).*(r.^k).^(1 - k))/t).^(k - 1)))
plot(r,L)
Answers (1)
You're missing the 'dot' in the "./" operator so ML is doing matrix division instead of element-wise...try
L=1 - (t*(r.^k).^(k - 1) - 1)./(k*(t - ((r.^(1/k).*(r.^k).^(1 - k))/t).^(k - 1)));
Categories
Find more on Surface and Mesh Plots 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!