Matlab plottting example

clear;
clc;
i=5;
FileName=sprintf('80kpa_force_%d.xlsx',i);
data=readmatrix(FileName,'Range','A1:B3');
x=data(5:5:end,1);
y=data(5:5:end,2);
y2=data(5:5:end,3);
n=length(y);
x_nor=linspace(1,n,n);
x_nor=x_nor';
%%%%%%%%%%% Fig. 1 %%%%%%%%%%%%%%
figure(1);
plot(x,y,'ko-',x,y,'ko--','LineWidth',2);
grid on
x0=10;
y0=10;
width=960;
height=540;
set(gcf,'Position',[x0,y0,width, height];
set(gca,'FontSize',20);
xlabel('Minutes','fontsize',20,'fontname','Times New Roman');
ylabel('force(KN)','fontsize',20,'fontname','Times New Roman');
legend('force 1','force 2');

%%%%%%%%%%% Export Images %%%%%%%%%%%%%%
ImageName=sprintf('80kpa_force_%d.jpg',i);
exportgraphics(gca,ImageName);
%%%%%%%%%%% Find peaks %%%%%%%%%%%%%%
[pks,locs]=findpeaks(y,x,'MinPeakDistance',0.8);
text(locs+.02,pks,num2str((1:numel(pks))'));
output=[locs,pks];
OutputName=sprintf('80kpa_force_peaks_%d.dat',i);
writematrix(output,OutputName,'Delimiter','tab');


figure(2);

 

posted @ 2024-01-11 22:47  kaiming_ai  阅读(13)  评论(0编辑  收藏  举报