How to plot heat map on the trajectory?

8 次查看(过去 30 天)
I want to create a heat map from trajectory data. In the code below, xLo and yLo are trajectory data. (Strictly speaking, it is xy coordinate data.) Also, FLo is the value that represents the scale of the heat map. Here, the trajectory data contains multiple trajectories. In other words, there are multiple trajectories from a starting point to a particular ending point. This time I want to draw a heat map of the trajectory using this data, but since the end point of one trajectory 1 is connected to the start point of the next trajectory 2, it should be drawn as a curve, but unnecessary space is created. I would like to remove this space before drawing the heatmap. Can someone please help me? This is done by writing each heat-mapped trajectory from the top using a for loop, but as the figure shows, a space is created between the start and end points.
clear all;
close all;
%% load date
load("FractalDimension_UpperD5_parabola.mat")
fLo = fd;
load("Reconstraction_UpperD5_parabola.mat")
AngleLo = ReconTra(:,1);
%% calucurate xy coodination
xLo = sin(AngleLo);
yLo = -cos(AngleLo);
XLo = zeros(N,1);
YLo = zeros(N,1);
FLo = zeros(N,1);
% getting Index of start point at each trajecory
startIndices = find(XLo == -1);
% dividing all trajectory date into each trajectory date
numTrajectories = numel(startIndices);
trajectoriesX = cell(1, numTrajectories);
trajectoriesY = cell(1, numTrajectories);
trajectoriesF = cell(1, numTrajectories);
for i = 1:numTrajectories
if i < numTrajectories
trajectoriesX{i} = XLo(startIndices(i):startIndices(i+1)-1);
trajectoriesY{i} = YLo(startIndices(i):startIndices(i+1)-1);
trajectoriesF{i} = FLo(startIndices(i):startIndices(i+1)-1);
else
trajectoriesX{i} = XLo(startIndices(i):end);
trajectoriesY{i} = YLo(startIndices(i):end);
trajectoriesF{i} = FLo(startIndices(i):end);
end
end
%%
figure;
% drawing heatmap on each trajectory
hold on;
for i = 1:numTrajectories
% gerating grid
xi = linspace(min(trajectoriesX{i}), max(trajectoriesX{i}), 100);
yi = linspace(min(trajectoriesY{i}), max(trajectoriesY{i}), 100);
[xi, yi] = meshgrid(xi, yi);
% liner spline
interpF = scatteredInterpolant(trajectoriesX{i}, trajectoriesY{i}, trajectoriesF{i}, 'linear', 'none');
% calucurate value of spline
zi = interpF(xi, yi);
% draw heatmap
surf(xi, yi, zi, 'EdgeColor', 'none', 'FaceColor', 'interp');
colormap(jet(256));
% setting behavior of heatmap
caxis([0 8]);
ylim([0 1]);
xlim([-1 1]);
colorbar;
h = gca;
h.FontSize = 15;
h.FontName = 'Times New Roman';
ylabel('Y coordination', 'fontSize', 18);
xlabel('X coordination', 'fontSize', 18);
zlabel('Fractal Dimension', 'fontSize', 18);
grid on;
view(2);
end
  1 个评论
Mathieu NOE
Mathieu NOE 2023-11-17
hello
you need to provide the mat files as well if you want someone to help you

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by