1、求和:sum函数
b = sum(a,dim);
2、求均值:mean函数
3、求方差:var函数
4、求均方差:std函数
5、求协方差:cov函数
确保输入向量为行向量:
X = X(:)';
确保输入向量为列向量:
X = X(:);
矩阵循环移动:
Y = circshift(A,K)
Y = circshift(A,K,dim)
在结果展示时,需设置数字保留小数为主,可采用round函数
round(Num, 位数)
在图形中在采用如下设置:
text( 'string',"\itR\rm_2="+round( R2( in, 1), 2 ) , 'Units','normalized','position',[0.2,0.92], 'FontSize',12,'FontWeight','Bold','FontName','Times New Roman');
基础设置如下:
figure(1)
hold on;
box on;
xlabel(X_name); % 后续调整坐标标题
ylabel(Y_name); % 后续调整坐标标题
set(gca,'xlim',[0 1],'xtick',[0:0.2:1],'xticklabel',[0:0.2:1] );
set(gca,'ylim',[0 1],'ytick',[0:0.2:1],'yticklabel',[0:0.2:1]);
text( 'string',"(a) Figure 1", 'Units','normalized','position',[0.02,0.9], 'FontSize',14,'FontWeight','Bold','FontName','Times New Roman');
hl = legend(h([1 2]),"Legend 1","Legend 2");
set(hl,'Box','off','NumColumns',2,'FontSize',14,'Fontname', 'Times New Roman');
set(gca,'FontSize',12,'Fontname', 'Times New Roman');
set(gca,'Layer','top');
子图位置设置:
figureUnits = 'centimeters';
figureWidth = 30;
figureHeight = 15;
figure(1)
set(gcf, 'Units', figureUnits, 'Position', [0 0 figureWidth figureHeight]);
可自定义图片格式,如’.tiff’,'.png’等等
clc
close all
clear
%% 导入数据
pathFigure= '.\Figures\' ;
Figure_name ='Figure 1';
str= strcat(pathFigure, Figure_name, '.tiff');
print(gcf, '-dtiff', '-r600', str);
绝对路径
相对路径
-当前路径
Matlab当前路径,用符号一个点“.”表示;
-上一级路径
Matlab上一级路径,用符号二个点“…”表示;