Change data tip so it shows temperature
6 views (last 30 days)
Show older comments
I have created a thermal model using matlab pde, and it works well. However, when opening the model in a figure window, the data tip function only shows X, Y, and Z data. I've tried looking for a way to change this so it shows the temperature at certain points (e.g when clicking anywhere on the model, it will show the temperature). Is there anyway I can do this? I feel like this should be intergrated somewhere in the window. Below is my code if needed.
u = symunit;
SIUnits = baseUnits('SI');
gm = multicuboid([2 2.1 2.7 3.2 20],[2.1 2.2 2.7 3.2 20],1.55);
thermalmodel = createpde('thermal','transient');
thermalmodel.Geometry = gm
pdegplot(thermalmodel,'CellLabels','on','FaceAlpha',0.5);
figure('Position',[10,10,800,400]);
subplot(1,2,1)
pdegplot(thermalmodel,'FaceAlpha',0.25,'CellLabel','on')
title('Geometry with Cell Labels')
subplot(1,2,2)
pdegplot(thermalmodel,'FaceAlpha',0.25,'FaceLabel','on')
title('Geometry with Face Labels')
generateMesh(thermalmodel,'Hmax',1);
Water at 30 degrees C
thermalProperties(thermalmodel,'ThermalConductivity',0.616,'SpecificHeat',4184,'MassDensity',997,'Cell',1);
304 stainless steel
thermalProperties(thermalmodel,'ThermalConductivity',16.2,'SpecificHeat',500,'MassDensity',8000,'Cell',2);
Soapstone
thermalProperties(thermalmodel,'ThermalConductivity',6.4,'SpecificHeat',980,'MassDensity',2980,'Cell',3);
Concrete
thermalProperties(thermalmodel,'ThermalConductivity',1.2,'SpecificHeat',880,'MassDensity',2400,'Cell',4);
Soil
thermalProperties(thermalmodel,'ThermalConductivity',6.4,'SpecificHeat',750,'MassDensity',2434,"Cell",5);
thermalmodel.StefanBoltzmannConstant = 5.670373E-8;
thermalBC(thermalmodel,'Temperature',353.15,'Face',[1 2 3 4 5 6]);
thermalIC(thermalmodel,277.65,'Cell',5);
thermalIC(thermalmodel,295.15,'Cell',1);
thermalIC(thermalmodel,293.15,'Cell',[2 3 4]);
thermalBC(thermalmodel,'AmbientTemperature',350.15,"Emissivity",0.38,"Face",[7 8 9 10 11 12]);
thermalBC(thermalmodel,'AmbientTemperature',313.15,'Emissivity',0.94,'Face',[19 20 21 22 23 24]);
thermalBC(thermalmodel,'HeatFlux',-4019.4,'Face',[7 8 9 10 11 12]);
thermalBC(thermalmodel,'HeatFlux',-240.67,'Face',[13 14 15 16 17 18]);
generateMesh(thermalmodel);
tlist = 10:100:86400;
Model after 24 hours (86400 seconds)
thermalresults = solve(thermalmodel,tlist);
T = thermalresults.Temperature;
pdeplot3D(thermalmodel,'ColorMapData',thermalresults.Temperature(:,end));
0 Comments
Accepted Answer
Alan Moses
on 13 Aug 2020
You can refer to datacursormode documentation which has an example of customizing data tips via a callback function. From my understanding the temperature data is present in the ‘T’ variable. To add customized data tips in the final 3D plot of your script, you can modify the following lines of code by appending this at the end of your script:
dcm = datacursormode;
dcm.UpdateFcn = {@displayCoordinates,T};
function txt = displayCoordinates(~,info,T)
x = info.Position(1);
y = info.Position(2);
z = info.Position(3);
%temp = T(appropriate indexing);
txt = ['(' num2str(x) ', ' num2str(y) ', ' num2str(z) ', ' num2str(temp) ')'];
end
Hope this helps!
8 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!