the code below I'm trying to plot a loglog graph, but everytime I run the code I keep getting an empty graph, then when i use the brush i can see the points. can anyone help
Show older comments
n=10;
x=0.2;
for i=1:n
h=1/i;
cf=dot([1 -2 1],[(cos(pi*(x+h))) cos(pi*x) cos(pi*(x-h))])/h^2;
rf=dot([2 -5 4 -1],[cos(pi*x) ;cos((pi*(x+h))) ;cos((pi*(x+2*h))); cos(pi*(x+3*h))])/h^2;
ec=abs((-pi^2*cos(pi*x))-cf);
er=abs((-pi^2*cos(pi*x))-rf);
loglog(h,ec,'g');
hold on
loglog(h,er,'r');
hold on
end
xlabel('h')
ylabel('ec + er')
Accepted Answer
More Answers (0)
Categories
Find more on Networks 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!