How to plot only few points in X axis and y axis

24 vues (au cours des 30 derniers jours)
shekar gundavarapu
shekar gundavarapu le 22 Juin 2018
I have certain points only to be plotted on x axis from over all length of the beam.
My beam length is 1 metres and i want to plot slope and deflection at only few points like 0.333, 0.666, etc distance of the beam. How can i do that . currently i am using below code to plot everything over the lenght. but i want to see only thos points listed.
x1=linspace(0,1,N);
x2=linspace(0,1,N);
figure
subplot(1,2,1)
plot (x1,d)
title('Length vs Displacement')
xlabel('Length')
ylabel('Displacement')
subplot(1,2,2)
plot (x2,s,'r-x')
title('Length vs Slope')
xlabel('Length')
ylabel('Slope')

Réponses (1)

Ameer Hamza
Ameer Hamza le 22 Juin 2018
Try this.
x=linspace(0,1,N);
xq = 0.333:0.333:1;
dNew = interp1(x, d, xq);
sNew = interp1(x, s, xq);
figure
subplot(1,2,1)
plot (xq, dNew)
title('Length vs Displacement')
xlabel('Length')
ylabel('Displacement')
subplot(1,2,2)
plot (xq, sNew,'r-x')
title('Length vs Slope')
xlabel('Length')
ylabel('Slope')
  6 commentaires
Ameer Hamza
Ameer Hamza le 23 Juin 2018
@shekar, since the code in your question already included N so I assumed that you already know what it is. Your question also shows that d and s have the same length. If it not the case, you can modify the code as follow
x1=linspace(0,1,length(d));
x2=linspace(0,1,length(s));
xq = 0.333:0.333:1;
dNew = interp1(x1, d, xq);
sNew = interp1(x2, s, xq);
figure
subplot(1,2,1)
plot (xq, dNew)
title('Length vs Displacement')
xlabel('Length')
ylabel('Displacement')
subplot(1,2,2)
plot (xq, sNew,'r-x')
title('Length vs Slope')
xlabel('Length')
ylabel('Slope')
shekar gundavarapu
shekar gundavarapu le 23 Juin 2018
Thank you..Will try and let you know

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by