Problem with x axis

Greetings! I'm having some trouble understanding the reason why my x-axis in a matlab plot appears the way it does. I've defined a limit for the x-axis variable(from -2 to 2) and in the plot it shows values from 0 to 4000.
This is my code:
clc;
clear all;
clf;
r=1;
ad=-2*r:0.001:2*r;
d=abs(ad);
Ai=2*r*acos(d./(2*r))-(d/2).*((4*r^2)-d.^2).^0.5;
A=Ai/(pi*r^2);
plot(A);
grid

Respuestas (1)

Honglei Chen
Honglei Chen el 30 de Oct. de 2013
Editada: Honglei Chen el 30 de Oct. de 2013

0 votos

You need to do
plot(ad,A)
otherwise the x axis is just the indices of elements in A

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Oct. de 2013

Comentada:

el 30 de Oct. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by