How to use a vector to make a graph?
2 views (last 30 days)
Show older comments
I want to use a vector to make a scatter plot. Ie, y(i)=v(i,1) from my vector. I managed to get from the vector to something resembling the results using a for loop, but I am unable to plot it from there. Here is the code I am using. The part I need help starts at the asterisks in the code. Thanks for the help!
a=1;
b=3;
c=-0.1;
d=0.2;
e=0.3;
n=10;
f=(b-a)/n;
A = toeplitz([2,-1,zeros(1,n-2)]);
A(1,1)=1;
A=(1/f)*A
u=zeros(n,1);
u(1,1)=e*f*(a/2+.2/6)-c;
for i=2:(n-1)
u(i,1)=e*f*(a+.2*((i)-1));
end
u(n,1)=e*f*(a+.2*(n-1))+d/.2;
v=A\u;
x=1:1:100;
y=-.3*(x.^3-27)/6+(.2+.3/2)*(x-3)+.2;
intervals = 1:1:n;
plot(x,y);
*****************************************************
for i=1:n
res(i)=v(i,1);
end
input=1:1:n;
plot(input,res(input));
0 Comments
Answers (1)
See Also
Categories
Find more on Discrete Data 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!