I want to divide x and y axis into 12 equal parts using grid lines with coordinates values seen visible in the respective places of x and y-axis
1 view (last 30 days)
Show older comments
Hi all,
I want to divide x and y-axis into 12 equal parts with coordinate value seen visible in the 12 parts in x and y-axis using grid lines. I attached my code below,
format long
x = [0.05 0.05155 0.053266 0.055186 0.057362 0.059865 0.062803 0.066341 0.070755 0.076552 0.084804 0.098318 0.121708 0.125774 0.125797];
y = [0.05155 0.053266 0.055186 0.057362 0.059865 0.062803 0.066341 0.070755 0.076552 0.084804 0.098318 0.121708 0.125774 0.125797 0.125797];
scatter(x, y, '*', 'b');
hold all
line (x, y)
plot(x, y, 'r')
grid on
axis([0 0.18 0 0.18])
0 Comments
Accepted Answer
KSSV
on 27 Jul 2017
Do interpolation using x qith equal 12 parts. Read about interp1.
x = [0.05 0.05155 0.053266 0.055186 0.057362 0.059865 0.062803 0.066341 0.070755 0.076552 0.084804 0.098318 0.121708 0.125774 0.125797];
y = [0.05155 0.053266 0.055186 0.057362 0.059865 0.062803 0.066341 0.070755 0.076552 0.084804 0.098318 0.121708 0.125774 0.125797 0.125797];
% interpolation
xi = linspace(min(x),max(x),12) ;
yi = interp1(x,y,xi) ;
scatter(xi, yi, '*', 'b');
hold all
line (xi, yi)
plot(xi, yi, 'r')
grid on
axis([0 0.18 0 0.18])
2 Comments
KSSV
on 27 Jul 2017
How it is the same previous plot? In (xi,yi) xi is divided into 12 equal parts....use (x,y) and (xi,yi) in plot and see.....
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots 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!