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

7 vues (au cours des 30 derniers jours)
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])

Réponse acceptée

KSSV
KSSV le 27 Juil 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 commentaires
vetri veeran
vetri veeran le 27 Juil 2017
It is not working then also I am getting the same previous plot.
KSSV
KSSV le 27 Juil 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.....

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by