Interpolation of a scatter plot
Show older comments
Hello ;I would be most grateful if someone could give me a helping hand. i have a scatter plot where the the third variable is velocity color coded for each pair of (x,y)I woud like to interpolate this plot to have more points.below is a figure of what i have and my code as well . thanks in advance.


the interpolated points are the red piont of the second figure is having just 9 pionts. i would like to apply that to the first figure which is what i have .
plotTypes = {'mean_velocity','std_velocity','mean_pd', 'std_pd'};
for i = 1: length(plotTypes)
figure
plotType = plotTypes{i};
%subplot(1,length(plotTypes), i);
hold all ;
legendLabels = cell(1,length(plotData));
for j = 1:length(plotData)
xPlot= plotData{j}.data(:, idx.x);
yPlot= plotData{j}.data(:, idx.(plotTypes{i}));
plot(xPlot,yPlot, '-o','color',k(j,:));
legendLabels{j} = ['Y = ', num2str(plotData{j}.y)];
end
legend(legendLabels);
title(plotTypes{i}, 'Interpreter', 'none');
xlabel('x position')
ylabel(plotTypes{i}, 'Interpreter', 'none')
end
%% Generating the 3D color plot
% figure
for i = 1: length(plotTypes)
figure
legendLabels = cell(1,length(plotData));
% subplot(1,length(plotTypes), i);
hold all
for N=1:size(plotData,2)
pz =150;
plotData{1,N}.data();
x=plotData{1,N}.data(:,1);
y= plotData{1,N}.data(:,2);
%if i ==3
% z= plotData{1,N}.data(:,(i+2));
%end% Z(:,N) =plotData{1,N}.data(:,(i+2));
scatter(x,y,pz,plotData{1,N}.data(:,(i+2)),'filled')
legendLabels{N} = ['Y = ', num2str(plotData{N}.y)];
end
%%Interpolation into a gridded data
%F =scatteredInterpolant(x,y,Z);
%[xq,yq]=meshgrid(linspace(20,230,100));
%cq =F(xq,yq);
%h=pcolor(xq,yq,cq)
%legendLabels{N} = ['Y = ', num2str(plotData{N}.y)];
legend(legendLabels);
title(['3D plot of position against ',plotTypes{i}], 'Interpreter', 'none')
xlabel('X(mm)')
ylabel('Y(mm)')
H = colorbar;
ylabel(H, plotTypes{i});
end
1 Comment
Akira Agata
on 17 Jun 2019
Accepted Answer
More Answers (1)
KSSV
on 17 Jun 2019
0 votes
Read about interp2, griddata. If not working attach your data.
1 Comment
Yannick Tabot Njami
on 17 Jun 2019
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!