How do I get my loglog plot to chose the correct interval?

1 Ansicht (letzte 30 Tage)
Marcus
Marcus am 13 Feb. 2015
Kommentiert: Geoff Hayes am 15 Feb. 2015
Hi, I'm trying to get a loglog plot to show the correct interval. The code is meant to show numerical derivation of sin(x), here is my code:
f = @(x) sin(x);
g = @(x) cos(x);
for i = 1:10
h(i,:) = 10^(-i);
end
x=1;
df = (f(x+h)-f(x))./h;
fel = abs(g(1)-df);
[df fel h];
figure(1)
hold on
loglog(h, fel)
grid on
xlabel('h')
ylabel('Fel')
When I plot it the plot only shows h and fel from 0 to 0.1. The interesting interval is from 10^-1 to 10^-10 for h and 10^-1 to 10^-8 for fel. How do I get the loglog plot to show this intervall, or at least any interval close enough? Thank you for any help.
  1 Kommentar
Geoff Hayes
Geoff Hayes am 15 Feb. 2015
Marcus - you could try xlim and ylim to set the x- and y-axis intervals. But (10^-10,10^-1) for the x-axis is not much different from what you have now. Are you sure that there will be something interesting to show there?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by