smoothed scatter plot matlab like excel

31 visualizaciones (últimos 30 días)
Shehab Abougamrah
Shehab Abougamrah el 25 de En. de 2021
Comentada: Star Strider el 26 de En. de 2021
I have this plot code which creats the plot as scattered but line, whereas I want it as excel scattered smooth
%%% loadx - STRAIN - DISPLACEMENT
X = [6;10;13;23];
Y = [3.78E-04;1.06E-03;1.78E-03;2.10E-03];
plot(X,Y,'-o')
hold on
Xv = [6;10;13;23];
Yv = [4.30E-03;4.10E-03;3.40E-03;3.74E-03];
plot(Xv,Yv,'-o')
ax = gca;
ax.YAxis.Exponent = 0;
xlabel('Nodes')
ylabel('Strain (Dimensionless) & Displacement (m)')
title('Grid Sensitivty')
legend('Displacement X','Strain x'

Respuesta aceptada

Star Strider
Star Strider el 25 de En. de 2021
Editada: Star Strider el 25 de En. de 2021
I have no idea what you want.
Try this:
X = [6;10;13;23];
Y = [3.78E-04;1.06E-03;1.78E-03;2.10E-03];
Xi = linspace(min(X), max(X), 50);
Yi = interp1(X, Y, Xi, 'pchip');
plot(X,Y,'ob')
hold on
hp(1) = plot(Xi, Yi, '-b', 'DisplayName','Displacement X');
Xv = [6;10;13;23];
Yv = [4.30E-03;4.10E-03;3.40E-03;3.74E-03];
Xvi = linspace(min(Xv), max(Xv), 50);
Yvi = interp1(Xv, Yv, Xvi, 'pchip');
plot(Xv,Yv,'or')
hp(2) = plot(Xvi, Yvi, '-r', 'DisplayName','Strain x');
ax = gca;
ax.YAxis.Exponent = 0;
xlabel('Nodes')
ylabel('Strain (Dimensionless) & Displacement (m)')
title('Grid Sensitivty')
legend(hp)
Make appropriate changes in the interp1 method argument to get the result you want.
EDIT — (25 Jan 2021 at 21:56)
Corrected legend entries.
EDIT — (25 Jan 2021 at 22:14)
Added plot figure.
.
  2 comentarios
Shehab Abougamrah
Shehab Abougamrah el 26 de En. de 2021
thanks that is what I want
Star Strider
Star Strider el 26 de En. de 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Más respuestas (1)

dpb
dpb el 25 de En. de 2021
fXY=fit(X,Y,'smoothingspline');
plot(fXY,X,Y,'b-')
fXYv=fit(Xv,Yv,'smoothingspline');
plot(fXYv,Xv,Yv,'r-')
Above needs Curve Fitting Toolbox but is probably by far the simplest approach if have.

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by