Filter löschen
Filter löschen

I want to fill in the gaps in a matrix (extrapolation) and produce nice looking plots such as this ->

4 Ansichten (letzte 30 Tage)
I have a plot attached (17.02.17) which was created using vectors and interpolation via binning (bindata2: http://xcorr.net/2013/12/23/fast-1d-and-2d-data-binning-in-matlab/). However, I want to create a nicer looking plot so that the image looks more smoother / higher definition (see higher def plot (17.13.33)- I didn't create).
Can someone tell me how I can do this via extrapolation (to fill in the gaps - if possible) i.e. to guess values where there are none? and also, which plotting functions are the nicest? at the moment, I'm only using imagesc and pcolor. Are there any better Matlab / external toolbox plotting functions that anyone knows of?
Here's some example code of where I am at the moment:
for d = 1:10;
val(d).field = data_split(d).SG.field;
val(d).y = data_split(d).SG.y;
val(d).x = data_split(d).SG.x;
end
x = [val(:).x];
y = [val(:).y];
field = [val(:).field];
x1rg = [7:0.020:9];
x2rg = [0:5:1000];
Output = bindata2(...
[field],... % Value to grid
[x],[y],... %x1 and x2 in the script, or your x and y locations in more general terms
x1rg,x2rg);
figure;
pcolor(x1rg(1:100),x2rg(1:200),Output);
shading flat;
colorbar
caxis([8 8.3]);
xlim([7.2 8.3]);
title('title','fontsize',22);
ylabel('y');
set(gca,'FontSize',16);
set(gca,'ydir','reverse')

Akzeptierte Antwort

Kelly Kearney
Kelly Kearney am 22 Jun. 2015
A scattered interpolant is probably going to be your best bet, assuming you're starting with data that isn't on a regular grid.
x = [val(:).x];
y = [val(:).y];
field = [val(:).field];
x1rg = [7:0.020:9];
x2rg = [0:5:1000];
[x1rg, x2rg] = meshgrid(x1rg, x2rg);
F = scatteredInterpolant(x, y, field, 'natural', 'nearest');
Output = F(x1rg, x2rg);
You can play around with different interpolation and extrapolation methods; I tend to like the natural/nearest combo for data like yours that has some larger missing patches on the edges.

Weitere Antworten (1)

Adam
Adam am 22 Jun. 2015
doc interp2
should do the job. There are examples on that page - it isn't totally intuitive to use first time. It is what I use for this kind of thing usually. I also use imagesc for plotting, I've never used pcolor not especially knew it existed so not sure what that does differently!

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by