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

回答(1 个)
Honglei Chen
2013-10-30
编辑:Honglei Chen
2013-10-30
You need to do
plot(ad,A)
otherwise the x axis is just the indices of elements in A
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!