How to use a vector to make a graph?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!