基于Matlab模拟交互式玻璃化转变分析仪 (DSC)

简介: 基于Matlab模拟交互式玻璃化转变分析仪 (DSC)

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法       神经网络预测       雷达通信      无线传感器        电力系统

信号处理              图像处理               路径规划       元胞自动机        无人机

⛄ 内容介绍

DSC作为一种主要的热分析方法,适用于各种固化体系,应用很普遍.文章介绍了DSC的相关基础知识,研究了利用DSC测定LED封装环氧树脂的玻璃化转变温度的测试条件,对不同的测试条件进行了比较和评定,并进行了相关测试

⛄ 完整代码

% Version 1.0

% Robin Hartley (PhD), University of Bristol, Bristol Composites, Institute, Bristol, United Kingdom


%      - This is a function that analyses dynamic DSC data for glass

%      transitions using a GUI which allows you to smooth the data

%      interactively and interactively select the analysis regions using

%      draggable verticle lines

%

%      - Variables:

%           Temperature - DSC temperature data (°C)

%           DSCsignal - DSC data (mW/mg)


%      - Outputs:

%           TgOnset - Glass transition onset

%           TgMid - Glass transition midpoint


%Here is a demonstration of how it works using a sin wave:


function [TgOnset,TgMid] = GlassTransitionFunc

% Define sine wave parameters

t = 0:0.01:1; % time vector

f = 1; % frequency of sine wave

A = 1; % amplitude of sine wave

sine_wave = A*sin(2*pi*f*t); % generate sine wave


% Add noise to sine wave

SNR = 25; % signal-to-noise ratio

noise_power = (norm(sine_wave)^2)/(length(sine_wave)*10^(SNR/10));

noise = sqrt(noise_power)*randn(size(sine_wave));

noisy_sine_wave = sine_wave + noise; % add noise to sine wave


Temp = t;

HeatFlow = noisy_sine_wave;


[TgOnset,TgMid] = TGLine(Temp,HeatFlow);

end


function [TgOnset,TgMid] = TGLine(xdata,ydata)

hLineToDrag = [];

smooth_ydata = sgolayfilt(ydata,3,11);   %Set up initially smoothed y signal


%Create figure window

h_fig = figure;

h_fig.UserData.isButtonDown = false;   %Create flag for mousedown event within figure


%Set up data associated with the figure handle

setappdata(h_fig,'xdata',xdata)

setappdata(h_fig,'ydata1',ydata)

setappdata(h_fig,'ydata2',smooth_ydata)


%Create axes window

h_ax1 = axes('unit','norm','Position',[0.1 0.22 0.85 0.75]);


%Select suitable axes limits and associate the figure handle

yrange = range(ydata);

xl = [min(xdata) max(xdata)];

yl = [min(ydata)-yrange*0.1 max(ydata)+yrange*0.1];

setappdata(h_fig,'xlims',xl);

setappdata(h_fig,'ylims',yl);

setappdata(h_fig,'axes_handle',h_ax1);   %associate axes with figure handle


%Plot data and initialise the draggable vertical lines

updatePlot(h_fig,h_ax1);

initiateVertLines(h_fig,h_ax1)


%Creat button used to save the data and figure

FinalTgButton = uicontrol('units','normalized','Position',[0.65 0.05 0.2 0.05],'String','OKAY',...

   'Callback', @FinaliseTgButton);


TgLinePlot(h_fig)


h_sld = uicontrol('Style', 'slider',...

   'Min',5,'Max',length(ydata)*0.3,'Value',25,...

   'unit','norm',...

   'Tag','Slider',...

   'Position', [0.05 0.05 0.4 0.05],...

   'Callback', @slider_callback);

%

setappdata(h_sld,'xdata',xdata)

setappdata(h_sld,'ydata1',ydata)

setappdata(h_sld,'ydata2',smooth_ydata)

setappdata(h_sld,'fig_handle',h_fig);

setappdata(h_sld,'axes_handle',h_ax1);

Framelengthtext = uicontrol('Style','text','String','Smoothing Framelength:','unit','norm','Position',[0 0.01 0.5 0.05]);

setappdata(h_sld,'valText', Framelengthtext);


set(h_fig, 'WindowButtonDownFcn', @my_downbutton_function);


% Define the persistent variables to store the values of a and b

persistent pTgOnset

persistent pTgMid

if isempty(pTgOnset) || isempty(pTgMid)

   pTgOnset = 0;

   pTgMid = 0;

end

% Wait for the figure to be closed

waitfor(h_fig);

% Return the values of a and b using the nested function

[pTgOnset, pTgMid] = getOutput();

TgOnset = pTgOnset;

TgMid = pTgMid;


   function my_downbutton_function(h_fig,~)

       % This is the callback function that will be called when the mouse button is pressed down on the figure

       % src: the source object that triggered the event (figure or axes handle)

       % event: the event data structure


       % Set a flag to indicate whether the mouse pointer is within the x range

       hVerticalLines = getappdata(h_fig,'VerticalLines');

       xVLC = get(hVerticalLines,'XData');

       xVertLineCoord1 = xVLC{1}(1);

       xVertLineCoord2 = xVLC{2}(1);

       x = getappdata(h_fig,'xdata');

       xrange = range(x);

       xpercentage = 0.00625;

       x_min1 = xVertLineCoord1-xrange*xpercentage;

       x_max1 = xVertLineCoord1+xrange*xpercentage;

       x_min2 = xVertLineCoord2-xrange*xpercentage;

       x_max2 = xVertLineCoord2+xrange*xpercentage;


       % Get the initial mouse press coordinates

       initial_coords = get(gca, 'CurrentPoint');

       initial_x = initial_coords(1,1);


       [~,I] = min(abs([xVertLineCoord1 xVertLineCoord2]-initial_x));


       if (initial_x >= x_min1 && initial_x <= x_max1) || (initial_x >= x_min2 && initial_x <= x_max2)

           in_x_range = true;

           set(h_fig, 'WindowButtonMotionFcn', @motion_callback_function);

           set(h_fig, 'WindowButtonUpFcn', @up_callback_function);

       else

           in_x_range = false;

       end


       function motion_callback_function(h_fig,~)

           % This is the callback function that will be called repeatedly while the mouse button is pressed down and the mouse is moving

           % src: the source object that triggered the event (figure or axes handle)

           % event: the event data structure


           % Get the current mouse coordinates

           current_coords = get(gca, 'CurrentPoint');


           % Check if the mouse is within the y range or has moved out of it

           if (initial_x >= x_min1 && initial_x <= x_max1) || (initial_x >= x_min2 && initial_x <= x_max2)

               in_x_range = false;

           end

           hLineToDrag = hVerticalLines(I);

           set(hLineToDrag,'XData',[current_coords(1, 1) current_coords(1, 1)]);

           updatePlot2(h_fig)

       end


       function up_callback_function(~,~)

           % This is the callback function that will be called when the mouse button is released

           % src: the source object that triggered the event (figure or axes handle)

           % event: the event data structure


           % Reset the 'WindowButtonMotionFcn' and 'WindowButtonUpFcn' callbacks

           set(gcf, 'WindowButtonMotionFcn', '');

           set(gcf, 'WindowButtonUpFcn', '');


           % Reset the in_y_range flag

           in_x_range = false;

       end

   end


   function updatePlot(h_fig,h_ax1)

       x = getappdata(h_fig,'xdata');

       y1 = getappdata(h_fig,'ydata1');

       y2 = getappdata(h_fig,'ydata2');

       xl = getappdata(h_fig,'xlims');

       yl = getappdata(h_fig,'ylims');

       h1 = plot(h_ax1,x,y1,'b');

       setappdata(h_fig,'NoisyLine',h1)

       hold on


       stack = dbstack();

       if numel(stack) > 1 && strcmp(stack(2).name,'TGLine')

           h2 = plot(h_ax1,x,y2,'r');

           setappdata(h_fig,'SmoothLine',h2)

       else

           if numel(stack) > 1 && strcmp(stack(2).name,'TGLine/slider_callback')

               h2 = getappdata(h_fig,'SmoothLine');

               delete(h2);

               h2 = plot(x,y2,'r');

               setappdata(h_fig,'SmoothLine',h2)

           end

       end


       legend([h1, h2],'Original signal','Smoothed signal');

       xlabel('Temperature / °C');

       ylabel('DSC Signal / mW mg^{-1}');

       xlim(xl);

       ylim(yl);

   end


   function initiateVertLines(h_fig,h_ax1)

       stack = dbstack();

       if numel(stack) > 1 && strcmp(stack(2).name,'TGLine')

           x = getappdata(h_fig,'xdata');

           randt = randi([1,round(length(x)/2)-1]);

           hVerticalLines = line([x(randt),x(randt)],get(h_ax1,'Ylim'),'Color','green');

           randt = randi([round(length(x)/2)+1,length(x)]);

           hVerticalLines = [hVerticalLines line([x(randt),x(randt)],get(h_ax1,'Ylim'),'Color','red')];


           setappdata(h_fig,'VerticalLines',hVerticalLines)

       end

   end


   function slider_callback(h_sld,~)

       y1 = getappdata(h_sld,'ydata1');

       h_fig = getappdata(h_sld,'fig_handle');

       h_ax1 = getappdata(h_sld,'axes_handle');

       Framelengthtext = getappdata(h_sld,'valText');


       framelen = floor(h_sld.Value/2)*2 + 1;

       order = 3;

       ymooth = sgolayfilt(y1,order,framelen);

       setappdata(h_fig,'ydata2',ymooth)


       set(Framelengthtext,'String',sprintf('Smoothing Framelength: %.0f', framelen));


       updatePlot(h_fig,h_ax1);

       updatePlot2(h_fig)

   end


   function TgLinePlot(h_fig)

       hVerticalLines = getappdata(h_fig,'VerticalLines');

       xl = getappdata(h_fig,'xlims');

       yl = getappdata(h_fig,'ylims');

       xx = getappdata(h_fig,'xdata');

       yy = getappdata(h_fig,'ydata2');


       %Find the gradient (FX)

       FX = zeros(length(xx),1);

       FX(1:length(xx)-1) = diff(yy)./diff(xx);

       FX(end) = FX(end-1);


       % Find equations for tangential lines at onset and end of Tg

       for i = 1:length(hVerticalLines)

           xVLC(i,:) = get(hVerticalLines(i),'XData');        %x coordinate of vertical lines

       end

       xVertLineCoord = xVLC(:,1);

       [~,I1] = min(abs(xx-xVertLineCoord(1)));       %index of vertical line 1

       [~,I2] = min(abs(xx-xVertLineCoord(2)));       %index of vertical line 2


       AvWinPM = 10;                                   %plus minus widow for gradient either side of index

       if I1 < AvWinPM+1

           Grad1 = mean(FX(1:I1+AvWinPM));

       else

           Grad1 = mean(FX(I1-AvWinPM:I1+AvWinPM));

       end

       if I2 > length(xx)-AvWinPM

           Grad2 = mean(FX(I2-AvWinPM:end));

       else

           Grad2 = mean(FX(I2-AvWinPM:I2+AvWinPM));

       end


       Int1 = yy(I1)-(xx(I1)*Grad1);     %tangent at index of line 1 intercept

       Int2 = yy(I2)-(xx(I2)*Grad2);     %tangent at index of line 2 intercept

       f1 = @(x) (Grad1*x)+Int1;         %function of tangent line 1

       f2 = @(x) (Grad2*x)+Int2;         %function of tangent line 2


       % Find equation for middle line

       % [M3,Ihalf] = min(abs(yy(I1:I2)-mean([yy(I1) yy(I2)])));      %find the index of the point that is closest to halfway between yy at I1 and I2

       [~,Ihalf] = max(abs(FX(I1:I2)));                           %find the point with highest gradient

       I3 = I1+Ihalf;


       if I3 < AvWinPM+1

           Grad3 = mean(FX(1:I3+AvWinPM));

       else

           if I3 > length(xx)-AvWinPM

               Grad3 = mean(FX(I3-AvWinPM:end));

           else

               Grad3 = mean(FX(I3-AvWinPM:I3+AvWinPM));       %find the gradient at that point

           end

       end


       Int3 = yy((I3))-(xx((I3))*Grad3);   %find the y intercept of middle line

       f3 = @(x) (Grad3*x)+Int3;     %function of middle line


       line1 = fplot(f1,[xx(1) xx(I2)],'Color','k','HandleVisibility','off');

       line2 = fplot(f2,[xx(I1) xx(end)],'Color','k','HandleVisibility','off');

       line3 = fplot(f3,[xx(I1) xx(I2)],'Color','k','HandleVisibility','off');


       x = sym('x');

       f4 = @(x) f1(x)-f3(x) == 0;

       ponsetx = double(solve(f4,x));

       ponsety = double(f1(ponsetx));


       f5 = @(x) f2(x)-f3(x) == 0;

       pfinishx = double(solve(f5,x));

       pfinishy = double(f2(pfinishx));


       ponset = plot(ponsetx,ponsety,'r*','HandleVisibility','off');

       pfinish = plot(pfinishx,pfinishy,'r*','HandleVisibility','off');

       %%IF USING THE MIDPOINT

       % pmidx = mean([ponsetx pfinishx]);

       % pmidy = mean([ponsety pfinishy]);

       %%IF USING THE MAX GRADIENT

       pmidx = xx(I3);

       pmidy = yy(I3);

       pmid = plot(pmidx,pmidy,'r*','HandleVisibility','off');


       OnsetAnnot = text(ponsetx,ponsety,['\leftarrow ''Onset = ' num2str(ponsetx,'%.1f') ' °C']);

       MidAnnot = text(pmidx,pmidy,['\leftarrow ''Mid = ' num2str(pmidx,'%.1f') ' °C']);


       xlim(xl);

       ylim(yl);


       setappdata(h_fig,'line1',line1)

       setappdata(h_fig,'line2',line2)

       setappdata(h_fig,'line3',line3)

       setappdata(h_fig,'ponset',ponset)

       setappdata(h_fig,'pfinish',pfinish)

       setappdata(h_fig,'pmid',pmid)

       setappdata(h_fig,'OnsetAnnot',OnsetAnnot)

       setappdata(h_fig,'MidAnnot',MidAnnot)

       setappdata(h_fig,'ponsetx',ponsetx)

       setappdata(h_fig,'pmidx',pmidx)

   end


   function updatePlot2(h_fig)

       line1 = getappdata(gcf,'line1');

       line2 = getappdata(gcf,'line2');

       line3 = getappdata(gcf,'line3');

       ponset = getappdata(gcf,'ponset');

       pfinish = getappdata(gcf,'pfinish');

       pmid = getappdata(gcf,'pmid');

       OnsetAnnot = getappdata(gcf,'OnsetAnnot');

       MidAnnot = getappdata(gcf,'MidAnnot');

       delete(line1)

       delete(line2)

       delete(line3)

       delete(ponset)

       delete(pfinish)

       delete(pmid)

       delete(OnsetAnnot)

       delete(MidAnnot)

       TgLinePlot(h_fig)

   end


   function FinaliseTgButton(~,~)

       ponsetx = getappdata(gcf,'ponsetx');

       pmidx = getappdata(gcf,'pmidx');

       pTgOnset = ponsetx;

       pTgMid = pmidx;

       % ResultsDir = uigetdir;

       % prompt = 'Enter filename to save';

       % dlgtitle = 'Input';

       % dims = [1 35];

       % savename = inputdlg(prompt,dlgtitle,dims);

       % savefig([ResultsDir '\' savename{1,1} '.fig'])

       close all

   end


   function [pTgOnsetOut, pTgMidOut] = getOutput()

       % Return the values of a and b

       pTgOnsetOut = pTgOnset;

       pTgMidOut = pTgMid;

   end


end

⛄ 运行结果

⛄ 参考文献

[1]林达儒, 谭艳娥, 龚丹雷,等. 利用DSC测定LED封装环氧树脂玻璃化转变温度[J]. 电子与封装, 2012, 12(10):5.

[2]蒙根, 许中强, 朱海燕. DSC法测定SMA共聚物玻璃化转变温度的影响因素[C]// 中国化工学会2008年学术年会. 0.

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料


相关文章
|
6月前
|
机器学习/深度学习 算法 计算机视觉
m基于yolov2网络的火焰烟雾检测系统matlab仿真,包含GUI界面
YOLOv2算法在MATLAB 2022a中用于火焰烟雾检测,展示了多张检测结果图,成功定位火源和烟雾。该系统基于单次前向传播的深度神经网络,关键改进包括网络架构优化和损失函数设计,结合分类和回归误差。训练涉及ResNet-50预训练模型,使用SGDM优化器,75%数据用于训练,剩余25%为测试。代码示例展示了网络构建、训练选项设置和目标检测器的训练过程。
42 1
|
6月前
|
机器学习/深度学习 算法 计算机视觉
m基于深度学习网络的性别识别系统matlab仿真,带GUI界面
m基于深度学习网络的性别识别系统matlab仿真,带GUI界面
66 2
|
6月前
|
机器学习/深度学习 算法 计算机视觉
m基于yolov2深度学习的车辆检测系统matlab仿真,带GUI操作界面
MATLAB 2022a中实现了YOLOv2目标检测算法的仿真,该算法从Darknet-19提取特征,以实时预测图像内目标的位置和类别。网络结构结合了网格划分、Anchor Boxes和多尺度预测,优化了边界框匹配。核心代码包括数据集划分、预训练ResNet-50加载、YOLOv2网络构建及训练。训练选项设置为GPU加速,使用&#39;sgdm&#39;优化器,200个周期进行训练。
63 2
m基于yolov2深度学习的车辆检测系统matlab仿真,带GUI操作界面
|
6月前
|
机器学习/深度学习 数据采集 人工智能
m基于深度学习网络的手势识别系统matlab仿真,包含GUI界面
m基于深度学习网络的手势识别系统matlab仿真,包含GUI界面
121 0
|
13天前
|
传感器 算法 vr&ar
六自由度Stewart控制系统matlab仿真,带GUI界面
六自由度Stewart平台控制系统是一种高精度、高稳定性的运动模拟装置,广泛应用于飞行模拟、汽车驾驶模拟、虚拟现实等领域。该系统通过六个独立的线性致动器连接固定基座与移动平台,实现对负载在三维空间内的六个自由度(三维平移X、Y、Z和三维旋转-roll、pitch、yaw)的精确控制。系统使用MATLAB2022a进行仿真和控制算法开发,核心程序包括滑块回调函数和创建函数,用于实时调整平台的位置和姿态。
|
4月前
|
算法 数据可视化 图形学
网络通信系统的voronoi图显示与能耗分析matlab仿真
在MATLAB2022a中,该程序模拟了两层基站网络,使用泊松分布随机生成Macro和Micro基站,并构建Voronoi图。它计算每个用户的信号强度,选择最强连接,并分析SINR和数据速率。程序还涉及能耗计算,包括传输、接收、处理和空闲能耗的分析。Voronoi图帮助可视化网络连接和优化能源效率。
|
2月前
|
算法
基于极大似然算法的系统参数辨识matlab仿真
本程序基于极大似然算法实现系统参数辨识,对参数a1、b1、a2、b2进行估计,并计算估计误差及收敛曲线,对比不同信噪比下的误差表现。在MATLAB2022a版本中运行,展示了参数估计值及其误差曲线。极大似然估计方法通过最大化观测数据的似然函数来估计未知参数,适用于多种系统模型。
|
3月前
|
机器学习/深度学习 监控 算法
基于深度学习网络的人员行为视频检测系统matlab仿真,带GUI界面
本仿真展示了基于GoogLeNet的人员行为检测系统在Matlab 2022a上的实现效果,无水印。GoogLeNet采用创新的Inception模块,高效地提取视频中人员行为特征并进行分类。核心程序循环读取视频帧,每十帧执行一次分类,最终输出最频繁的行为类别如“乐队”、“乒乓球”等。此技术适用于智能监控等多个领域。
70 4
|
4月前
|
算法
六自由度Stewart平台的matlab模拟与仿真
**摘要** 探索MATLAB2022a模拟6-DOF Stewart平台,模拟动态变化及伺服角度。平台实现XYZ平移及绕XYZ轴旋转。结构含中心动平台、固定基座及6个伺服驱动的伸缩连杆。运动学原理涉及球铰/虎克铰的转动自由度。通过动力学分析解决输入力矩到平台加速度的转换。核心算法与模型揭示了平台的精密定位能力。仿真结果显示动态性能。
|
5月前
|
机器学习/深度学习 算法 固态存储
m基于深度学习的卫星遥感图像轮船检测系统matlab仿真,带GUI操作界面
在MATLAB 2022a中,使用GoogLeNet对卫星遥感图像进行轮船检测,展示了高效的目标识别。GoogLeNet的Inception架构结合全局平均池化增强模型泛化性。核心代码将图像切块并分类,预测为轮船的部分被突出显示,体现了深度学习在复杂场景检测中的应用。
399 8