G11-Sundary-研究matlab-mcr

这些MATLAB脚本主要涉及从CSV和自定义格式文件中导入数据,然后使用散点图和线图对时间序列数据进行可视化。颜色映射被用来区分不同数据集,同时保存生成的图像为PNG和EPS格式。

plot_stobj.m
 

clearvars; clc; % plot_stobj.m
ta_2mu32=importdata("data\stobj\ta_2mu32");
ta_3mu32=importdata("data\stobj\ta_3mu32");
ta_2th32=importdata("data\stobj\ta_2th32");

fig1=figure(1);
% set(gca,'ylim',[0,1]); hold on;
x_1=ta_2mu32(:,1); y_1=ta_2mu32(:,2);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color='blue';
x_1=ta_2th32(:,1); y_1=ta_2th32(:,2);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color='red';
x_1=ta_3mu32(:,1); y_1=ta_3mu32(:,2);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color='blue';
xL1=xlabel('Time (s)'); hold on; xL1.FontSize = 17;
yL1=ylabel('VOF'); hold on; yL1.FontSize = 17;

plotDB1.m
 

clearvars; clc; % plotDB1.m
DB1ZX=importdata(".\data\damB\DB1ZX.csv");
DB1WU=importdata(".\data\damB\DB1WU.csv");
DBN1ZX=importdata(".\data\damB\DBN1ZX.csv");
DBN1WU=importdata(".\data\damB\DBN1WU.csv");
DB1mu=importdata(".\data\damB\t_Ux");
DBN1mu=importdata(".\data\damB\t_Fx");

fig1=figure(1);
set(gca,'xlim',[0,2.5],'ylim',[-0.5,4]); hold on;
x=DB1ZX(:,1); y=DB1ZX(:,2);
sc1=scatter(x,y); hold on;
sc1.SizeData=40; sc1.MarkerEdgeColor='Red'; sc1.Marker='x';
x=DB1WU(:,1); y=DB1WU(:,2);
sc1=scatter(x,y); hold on;
sc1.SizeData=40; sc1.MarkerEdgeColor='Blue'; sc1.Marker='^';
x=DB1mu(:,1); y=DB1mu(:,2);
plt1=plot(x,y); hold on; plt1.LineWidth = 1.5; plt1.Color = 'Black';
xL1=xlabel('Time (s)'); hold on; xL1.FontSize = 17;
yL1=ylabel('Ux (m/s)'); hold on; yL1.FontSize = 17;

fig2=figure(2);
set(gca,'xlim',[0,2.5],'ylim',[-15,45]); hold on;
x=DBN1ZX(:,1); y=DBN1ZX(:,2);
sc1=scatter(x,y); hold on;
sc1.SizeData=40; sc1.MarkerEdgeColor='Red'; sc1.Marker='x';
x=DBN1WU(:,1); y=DBN1WU(:,2);
sc1=scatter(x,y); hold on;
sc1.SizeData=40; sc1.MarkerEdgeColor='Blue'; sc1.Marker='^';
x=DBN1mu(:,1); y=DBN1mu(:,3);
plt1=plot(x,y); hold on; plt1.LineWidth = 1.5; plt1.Color = 'Black';
xL1=xlabel('Time (s)'); hold on; xL1.FontSize = 17;
yL1=ylabel('Fx (N)'); hold on; yL1.FontSize = 17;

rc_Tmepe_t125.m
 

clearvars; clc; % rc_Tmepe_t125.m
bkg_mat=importdata("data\gL\rc_bkg");
g0L1_mat=importdata("data\gL\rc_g0L1");
g0L2_mat=importdata("data\gL\rc_g0L2");
g0L3_mat=importdata("data\gL\rc_g0L3");
g0L4_mat=importdata("data\gL\rc_g0L4");
g0L5_mat=importdata("data\gL\rc_g0L5");
g1L1_mat=importdata("data\gL\rc_g1L1");
g1L2_mat=importdata("data\gL\rc_g1L2");
g1L3_mat=importdata("data\gL\rc_g1L3");
g1L4_mat=importdata("data\gL\rc_g1L4");
g1L5_mat=importdata("data\gL\rc_g1L5");

a1=0:0.2:1; a1 = a1(1,2:size(a1,2));

fig1=figure(1);
x_0=bkg_mat(:,1); y_0=bkg_mat(:,2);
plt0=plot(x_0,y_0); hold on; plt0.LineWidth=1.5; plt0.Color=[0,0,0];
x_1=g0L1_mat(:,1); y_1=g0L1_mat(:,2);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color=[0,0,1,a1(1)];
x_2=g0L2_mat(:,1); y_2=g0L2_mat(:,2);
plt2=plot(x_2,y_2); hold on; plt2.LineWidth=1.5; plt2.Color=[0,0,1,a1(2)];
x_3=g0L3_mat(:,1); y_3=g0L3_mat(:,2);
plt3=plot(x_3,y_3); hold on; plt3.LineWidth=1.5; plt3.Color=[0,0,1,a1(3)];
x_4=g0L4_mat(:,1); y_4=g0L4_mat(:,2);
plt4=plot(x_4,y_4); hold on; plt4.LineWidth=1.5; plt4.Color=[0,0,1,a1(4)];
x_4=g0L4_mat(:,1); y_4=g0L4_mat(:,2);
plt4=plot(x_4,y_4); hold on; plt4.LineWidth=1.5; plt4.Color=[0,0,1,a1(4)];
x_5=g0L5_mat(:,1); y_5=g0L5_mat(:,2);
plt5=plot(x_5,y_5); hold on; plt5.LineWidth=1.5; plt5.Color=[0,0,1,a1(5)];
x_6=g1L1_mat(:,1); y_6=g1L1_mat(:,2);
plt6=plot(x_6,y_6); hold on; plt6.LineWidth=1.5; plt6.Color=[1,0,0,a1(1)];
x_7=g1L2_mat(:,1); y_7=g1L2_mat(:,2);
plt7=plot(x_7,y_7); hold on; plt7.LineWidth=1.5; plt7.Color=[1,0,0,a1(2)];
x_8=g1L3_mat(:,1); y_8=g1L3_mat(:,2);
plt8=plot(x_8,y_8); hold on; plt8.LineWidth=1.5; plt8.Color=[1,0,0,a1(3)];
x_9=g1L4_mat(:,1); y_9=g1L4_mat(:,2);
plt9=plot(x_9,y_9); hold on; plt9.LineWidth=1.5; plt9.Color=[1,0,0,a1(4)];
x_10=g1L5_mat(:,1); y_10=g1L5_mat(:,2);
plt10=plot(x_10,y_10); hold on; plt10.LineWidth=1.5; plt10.Color=[1,0,0,a1(5)];
xL1 = xlabel('time(s)'); yL1 = ylabel('Em'); xL1.FontSize = 15; yL1.FontSize = 15;
saveas(gcf,'tmErc2.png'); saveas(gcf,'tmErc2.eps','epsc2'); close all;

fig2=figure(2);
x_0=bkg_mat(:,1); y_0=bkg_mat(:,3);
plt0=plot(x_0,y_0); hold on; plt0.LineWidth=1.5; plt0.Color=[0,0,0];
x_1=g0L1_mat(:,1); y_1=g0L1_mat(:,3);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color=[0,0,1,a1(1)];
x_2=g0L2_mat(:,1); y_2=g0L2_mat(:,3);
plt2=plot(x_2,y_2); hold on; plt2.LineWidth=1.5; plt2.Color=[0,0,1,a1(2)];
x_3=g0L3_mat(:,1); y_3=g0L3_mat(:,3);
plt3=plot(x_3,y_3); hold on; plt3.LineWidth=1.5; plt3.Color=[0,0,1,a1(3)];
x_5=g0L5_mat(:,1); y_5=g0L5_mat(:,3);
plt5=plot(x_5,y_5); hold on; plt5.LineWidth=1.5; plt5.Color=[0,0,1,a1(5)];
x_6=g1L1_mat(:,1); y_6=g1L1_mat(:,3);
plt6=plot(x_6,y_6); hold on; plt6.LineWidth=1.5; plt6.Color=[1,0,0,a1(1)];
x_7=g1L2_mat(:,1); y_7=g1L2_mat(:,3);
plt7=plot(x_7,y_7); hold on; plt7.LineWidth=1.5; plt7.Color=[1,0,0,a1(2)];
x_8=g1L3_mat(:,1); y_8=g1L3_mat(:,3);
plt8=plot(x_8,y_8); hold on; plt8.LineWidth=1.5; plt8.Color=[1,0,0,a1(3)];
x_9=g1L4_mat(:,1); y_9=g1L4_mat(:,3);
plt9=plot(x_9,y_9); hold on; plt9.LineWidth=1.5; plt9.Color=[1,0,0,a1(4)];
x_10=g1L5_mat(:,1); y_10=g1L5_mat(:,3);
plt10=plot(x_10,y_10); hold on; plt10.LineWidth=1.5; plt10.Color=[1,0,0,a1(5)];
xL1 = xlabel('time(s)'); yL1 = ylabel('Ep'); xL1.FontSize = 15; yL1.FontSize = 15;
saveas(gcf,'tpErc2.png'); saveas(gcf,'tpErc2.eps','epsc2'); close all;


rs_Tmepe_t125.m
 

clearvars; clc; % rs_Tmepe_t125.m
bkg_mat=importdata("data\gL\rs_bkg");
g0L1_mat=importdata("data\gL\rs_g0L1");
g0L2_mat=importdata("data\gL\rs_g0L2");
g0L4_mat=importdata("data\gL\rs_g0L4");
g0L5_mat=importdata("data\gL\rs_g0L5");
g1L1_mat=importdata("data\gL\rs_g1L1");
g1L2_mat=importdata("data\gL\rs_g1L2");
g1L3_mat=importdata("data\gL\rs_g1L3");
g1L4_mat=importdata("data\gL\rs_g1L4");
g1L5_mat=importdata("data\gL\rs_g1L5");

a1=0:0.2:1; a1 = a1(1,2:size(a1,2));
fig1=figure(1);
x_0=bkg_mat(:,1); y_0=bkg_mat(:,2);
plt0=plot(x_0,y_0); hold on; plt0.LineWidth=1.5; plt0.Color=[0,0,0];
x_1=g0L1_mat(:,1); y_1=g0L1_mat(:,2);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color=[0,0,1,a1(1)];
x_2=g0L2_mat(:,1); y_2=g0L2_mat(:,2);
plt2=plot(x_2,y_2); hold on; plt2.LineWidth=1.5; plt2.Color=[0,0,1,a1(2)];
x_4=g0L4_mat(:,1); y_4=g0L4_mat(:,2);
plt4=plot(x_4,y_4); hold on; plt4.LineWidth=1.5; plt4.Color=[0,0,1,a1(4)];
x_5=g0L5_mat(:,1); y_5=g0L5_mat(:,2);
plt5=plot(x_5,y_5); hold on; plt5.LineWidth=1.5; plt5.Color=[0,0,1,a1(5)];
x_6=g1L1_mat(:,1); y_6=g1L1_mat(:,2);
plt6=plot(x_6,y_6); hold on; plt6.LineWidth=1.5; plt6.Color=[1,0,0,a1(1)];
x_7=g1L2_mat(:,1); y_7=g1L2_mat(:,2);
plt7=plot(x_7,y_7); hold on; plt7.LineWidth=1.5; plt7.Color=[1,0,0,a1(2)];
x_8=g1L3_mat(:,1); y_8=g1L3_mat(:,2);
plt8=plot(x_8,y_8); hold on; plt8.LineWidth=1.5; plt8.Color=[1,0,0,a1(3)];
x_9=g1L4_mat(:,1); y_9=g1L4_mat(:,2);
plt9=plot(x_9,y_9); hold on; plt9.LineWidth=1.5; plt9.Color=[1,0,0,a1(4)];
x_10=g1L5_mat(:,1); y_10=g1L5_mat(:,2);
plt10=plot(x_10,y_10); hold on; plt10.LineWidth=1.5; plt10.Color=[1,0,0,a1(5)];
xL1 = xlabel('time(s)'); yL1 = ylabel('Em'); xL1.FontSize = 15; yL1.FontSize = 15;
saveas(gcf,'tmErs2.png'); saveas(gcf,'tmErs2.eps','epsc2'); close all;

fig2=figure(2);
x_0=bkg_mat(:,1); y_0=bkg_mat(:,3);
plt0=plot(x_0,y_0); hold on; plt0.LineWidth=1.5; plt0.Color=[0,0,0];
x_1=g0L1_mat(:,1); y_1=g0L1_mat(:,3);
plt1=plot(x_1,y_1); hold on; plt1.LineWidth=1.5; plt1.Color=[0,0,1,a1(1)];
x_2=g0L2_mat(:,1); y_2=g0L2_mat(:,3);
plt2=plot(x_2,y_2); hold on; plt2.LineWidth=1.5; plt2.Color=[0,0,1,a1(2)];
x_4=g0L4_mat(:,1); y_4=g0L4_mat(:,3);
plt4=plot(x_4,y_4); hold on; plt4.LineWidth=1.5; plt4.Color=[0,0,1,a1(4)];
x_5=g0L5_mat(:,1); y_5=g0L5_mat(:,3);
plt5=plot(x_5,y_5); hold on; plt5.LineWidth=1.5; plt5.Color=[0,0,1,a1(5)];
x_6=g1L1_mat(:,1); y_6=g1L1_mat(:,3);
plt6=plot(x_6,y_6); hold on; plt6.LineWidth=1.5; plt6.Color=[1,0,0,a1(1)];
x_7=g1L2_mat(:,1); y_7=g1L2_mat(:,3);
plt7=plot(x_7,y_7); hold on; plt7.LineWidth=1.5; plt7.Color=[1,0,0,a1(2)];
x_8=g1L3_mat(:,1); y_8=g1L3_mat(:,3);
plt8=plot(x_8,y_8); hold on; plt8.LineWidth=1.5; plt8.Color=[1,0,0,a1(3)];
x_9=g1L4_mat(:,1); y_9=g1L4_mat(:,3);
plt9=plot(x_9,y_9); hold on; plt9.LineWidth=1.5; plt9.Color=[1,0,0,a1(4)];
x_10=g1L5_mat(:,1); y_10=g1L5_mat(:,3);
plt10=plot(x_10,y_10); hold on; plt10.LineWidth=1.5; plt10.Color=[1,0,0,a1(5)];
xL1 = xlabel('time(s)'); yL1 = ylabel('Ep'); xL1.FontSize = 15; yL1.FontSize = 15;
saveas(gcf,'tpErs2.png'); saveas(gcf,'tpErs2.eps','epsc2'); close all;


2Dshear.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!PlotType = Cartesian2D
$!TwoDAxis XDetail{RangeMin = 0.0}
$!TwoDAxis XDetail{RangeMax = 1.0}
$!TwoDAxis AxisMode = Independent
$!TwoDAxis YDetail{RangeMin = 0.0}
$!TwoDAxis YDetail{RangeMax = 1.0}
$!TwoDAxis YDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis YDetail{AxisLine{Show = No}}
$!TwoDAxis XDetail{Ticks{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{TickLabel{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{Title{ShowOnAxisLine = No}}
$!TwoDAxis XDetail{AxisLine{Show = No}}
$!View MakeCurrentViewNice
$!FrameLayout ShowBorder = No
$!TwoDAxis GridArea{DrawBorder = No}
$!FieldLayers ShowContour = Yes
$!GlobalTime SolutionTime = 0.05
$!FieldMap [4]  Shade{Show = No}
$!FieldMap [4]  Contour{ContourType = Lines}
$!SetContourVar 
  Var = 'alpha1'
  ContourGroup = 1
$!ContourLevels New
  ContourGroup = 1
  RawData
1
0.5
$!FieldMap [4]  Contour{LinePattern = Solid}
$!FieldMap [4]  Contour{PatternLength = 0.5}
$!FieldMap [4]  Contour{LineThickness = 0.5}
$!GlobalContour 1  Legend{Show = No}
$!FieldMap [4]  Mesh{Color = Custom2}
$!FieldMap [4]  Contour{Color = Red}

3DdamBreak.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!FrameName = 'alpha.water'
$!GlobalTime SolutionTime = 0.0
$!ThreeDView 
  PSIAngle = 60.0
  ThetaAngle = 145.0
  AlphaAngle = 0.0
  ViewerPosition
    {
    X = -4.55
    Y = 7.75
    Z = 5.6
    }
  ViewWidth = 1.6
$!ActiveFieldMaps -= [2]
$!ActiveFieldMaps -= [3]
$!IsoSurfaceLayers Show = Yes
$!IsoSurfaceAttributes 1  DefinitionContourGroup = 1
$!SetContourVar 
  Var = 'alpha.water'
  ContourGroup = 1
$!ContourLevels Add
  ContourGroup = 1
  RawData
1
0.5
$!IsoSurfaceAttributes 1  Shade{Show = Yes}
$!IsoSurfaceAttributes 1  IsoSurfaceSelection = ThreeSpecificValues
$!IsoSurfaceAttributes 1  Isovalue1 = 0.5
$!IsoSurfaceAttributes 1  Isovalue2 = 0.75
$!IsoSurfaceAttributes 1  Isovalue3 = 0.25
$!IsoSurfaceAttributes 1  Contour{Show = No}
$!GlobalContour 1  Legend{Show = No}
$!IsoSurfaceAttributes 1  Shade{Color = Blue}
$!ThreeDAxis FrameAxis{Show = No}
$!IsoSurfaceAttributes 1  Effects{UseTranslucency = Yes}
$!IsoSurfaceAttributes 1  Effects{SurfaceTranslucency = 70}
$!FrameLayout ShowBorder = No
$!FieldLayers ShowEdge = Yes
$!FieldMap [1]  EdgeLayer{Show = Yes}
$!View FitSurfaces
  ConsiderBlanking = Yes
$!FieldMap [4]  Shade{Color = Yellow}
$!RedrawAll
$!CreateNewFrame 
  XYPos
    {
    X = 1.0
    Y = 2.0
    }
  Width = 9.0
  Height = 6.0
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!LOOP 11
$!VARSET |time| = (0.25*(|LOOP|-1))
$!FrameControl ActivateByNumber
  Frame = 1
$!GlobalTime SolutionTime = |time|
$!VARSET |times| = (|time|*100)
$!VARSET |FNAME| = "damBreak3d|times|"
$!FrameControl ActivateByNumber
  Frame = 2
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup PrintRenderType = Image
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.eps'
$!Export 
  ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.jpeg'
$!Export 
  ExportRegion = CurrentFrame
$!ENDLOOP
# $!QUIT

3DdamBreakOver.mcr

#!MC 1410
$!PAGECONTROL CLEAR
$!ReadDataSet  '"StandardSyntax" "1.0" "FEALoaderVersion" "436" "FILENAME_File" "C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\case\system\controlDict" "AutoAssignStrandIDs" "Yes"'
  DataSetReader = 'OpenFOAM (FEA)'
$!FrameName = 'alpha.water'
$!GlobalTime SolutionTime = 0.0
$!ThreeDView 
  PSIAngle = 60.0
  ThetaAngle = 145.0
  AlphaAngle = 0.0
  ViewerPosition
    {
    X = -4.55
    Y = 7.75
    Z = 5.6
    }
  ViewWidth = 1.6
$!ActiveFieldMaps -= [2]
$!ActiveFieldMaps -= [3]
$!ActiveFieldMaps -= [5]
$!IsoSurfaceLayers Show = Yes
$!IsoSurfaceAttributes 1  DefinitionContourGroup = 1
$!SetContourVar 
  Var = 'alpha.water'
  ContourGroup = 1
$!ContourLevels Add
  ContourGroup = 1
  RawData
1
0.5
$!IsoSurfaceAttributes 1  Shade{Show = Yes}
$!IsoSurfaceAttributes 1  IsoSurfaceSelection = ThreeSpecificValues
$!IsoSurfaceAttributes 1  Isovalue1 = 0.5
$!IsoSurfaceAttributes 1  Isovalue2 = 0.75
$!IsoSurfaceAttributes 1  Isovalue3 = 0.25
$!IsoSurfaceAttributes 1  Contour{Show = No}
$!GlobalContour 1  Legend{Show = No}
$!IsoSurfaceAttributes 1  Shade{Color = Blue}
$!ThreeDAxis FrameAxis{Show = No}
$!IsoSurfaceAttributes 1  Effects{UseTranslucency = Yes}
$!IsoSurfaceAttributes 1  Effects{SurfaceTranslucency = 70}
$!FrameLayout ShowBorder = No
$!FieldLayers ShowEdge = Yes
$!FieldMap [1]  EdgeLayer{Show = Yes}
$!View FitSurfaces
  ConsiderBlanking = Yes
$!FieldMap [4]  Shade{Color = Yellow}
$!RedrawAll
$!CreateNewFrame 
  XYPos
    {
    X = 1.0
    Y = 2.0
    }
  Width = 9.0
  Height = 6.0
$!FrameLayout ShowBorder = No
$!FrameLayout IsTransparent = Yes
$!FrameName = 'Frame Front'
$!LOOP 11
$!VARSET |time| = (0.25*(|LOOP|-1))
$!FrameControl ActivateByNumber
  Frame = 1
$!GlobalTime SolutionTime = |time|
$!VARSET |times| = (|time|*100)
$!VARSET |FNAME| = "damBreak3d|times|"
$!FrameControl ActivateByNumber
  Frame = 2
$!ExportSetup ExportFormat = EPS
$!ExportSetup ImageWidth = 960
$!ExportSetup PrintRenderType = Image
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.eps'
$!Export 
  ExportRegion = CurrentFrame
$!ExportSetup ExportFormat = JPEG
$!ExportSetup ExportRegion = CurrentFrame
$!ExportSetup ImageWidth = 1000
$!ExportSetup ExportFName = 'C:\myPC\myFile\SJTU_G11\Sundry\research\postPro\|FNAME|.jpeg'
$!Export 
  ExportRegion = CurrentFrame
$!ENDLOOP
# $!QUIT

### MCR-ALS算法在Matlab中的实现 MCR-ALS (Multivariate Curve Resolution with Alternating Least Squares) 是一种用于解析复杂混合物光谱数据的技术,在化学计量学领域广泛应用。该方法通过交替最小二乘法迭代优化浓度矩阵和纯组分光谱矩阵。 #### 基本原理 MCR-ALS 的目标是从实验获得的数据集中提取出未知数量的成分及其对应的光谱特征。假设给定一个大小为 \(m \times n\) 的数据矩阵 \(D\),其中每一列表示一次测量得到的不同波长下的响应值,则可以表示成两个低秩矩阵相乘的形式: \[ D ≈ CS^T \] 这里 \(C\) 表示尺寸为 \(m \times p\) 的浓度矩阵;\(S\) 则是一个 \(n \times p\) 维度的纯物质光谱矩阵;而 \(p\) 就是要分解出来的潜在因子数目[^1]。 #### 实现步骤概述 为了实现在 MATLAB 中执行上述过程的功能模块,通常会遵循如下几个方面来构建程序框架: - 初始化参数设置; - 构建约束条件函数; - 编写核心求解循环体; - 输出结果可视化处理。 下面给出一段简单的伪代码作为参考,具体细节可能依据实际应用场景有所调整: ```matlab function [C,S] = mcr_als(D,p,options) % Initialization phase omitted here while not converged do % Fix S and update C using non-negative least squares solver C = nnls(S,D); % Apply any additional constraints on C if necessary % Fix C and update S similarly S = nnls(C',D'); % Apply any additional constraints on S if necessary check convergence criteria; end end ``` 此段代码展示了如何利用非负最小二乘法更新每一轮次内的变量估计,并施加必要的物理意义上的限制(比如非负性)。值得注意的是,真实世界里的应用往往还需要考虑更多因素,例如噪声抑制、初始猜测的选择等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jmsyh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值