I need to draw the annexed Excel draw with MATLAB code

3 次查看(过去 30 天)
I have a draw with Excel and I need please a MATLAB code to redraw it
Please see the annexed file
Thanks in advance

回答(1 个)

Voss
Voss 2024-4-11
x = [-5.5,-5,-4.5,-3.5,-2.5,-1.5,0,1.5,2.5,3.5,4.5,5,5.5];
y = [-0.002,-0.004,-0.005,-0.008,-0.008,-0.014,-0.014,-0.014,-0.008,-0.008,-0.005,-0.004,-0.002];
xi = linspace(min(x),max(x),100);
yi = interp1(x,y,xi,'spline');
figure();
hold on
plot(x,y,'.', ...
'Color',[0.65,0.65,0.65], ...
'MarkerSize',10)
plot(xi,yi,'-', ...
'Color',[0.65,0.65,0.65], ...
'LineWidth',1.5)
h_lgd = plot(NaN,NaN,'.-', ...
'Color',[0.65,0.65,0.65], ...
'MarkerSize',10, ...
'LineWidth',1.5);
legend(h_lgd,'g_M', ...
'Location','SouthOutside', ...
'Interpreter','none', ...
'Box','off')
ax = gca();
set(ax.Title, ...
'String','g_M', ...
'Interpreter','none', ...
'FontSize',12, ...
'VerticalAlignment','bottom', ...
'Position',[0 0.0025], ...
'FontWeight','normal')
set(ax, ...
'XLim',[-8,8], ...
'YLim',[-0.016,0], ...
'XAxisLocation','origin', ...
'YAxisLocation','origin', ...
'XGrid','on', ...
'YGrid','on', ...
'XMinorGrid','on', ...
'YMinorGrid','on', ...
'XTick',-8:2:8, ...
'YTick',-0.016:0.002:0, ...
'TickLength',[0 0], ...
'PlotBoxAspectRatio',[4 1 1], ...
'Box','on', ...
'FontSize',9)
ax.XAxis.TickLabelFormat = '%.3f';
ax.YAxis.TickLabelFormat = '%.3f';

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

产品


版本

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by