Filter löschen
Filter löschen

How to interpolate to fill zeros in two-dimensional data

4 Ansichten (letzte 30 Tage)
장훈 정
장훈 정 am 18 Jul. 2023
Beantwortet: Chunru am 18 Jul. 2023
load power
L2 = 200;
unitstep = 1;
% xv = (unique([L2:-unitstep:0,0:-unitstep:-L2],'stable')); % +L/2 부터 -L/2 까지 unit-step 행렬생성
% yv = (unique([L2:-unitstep:0,0:-unitstep:-L2],'stable')); % -L/2 부터 +L/2 까지 unit-step 행렬생성
xv = unique(0:400,'stable'); % +L/2 부터 -L/2 까지 unit-step 행렬생성
yv = unique(0:400,'stable'); % -L/2 부터 +L/2 까지 unit-step 행렬생성
[X, Y] = meshgrid(xv,yv);
F_mesh = [X(:),Y(:)]; % 1열 행렬로 변환
Nf = size(F_mesh,1);
xvv = xv; yvv = yv;
Nx = numel(xvv); Ny = numel(yvv);
figure(1)
subplot 121
imagesc(xvv,yvv,power);
axis equal
xlim([0 400])
ylim([0 400])
set(gca,'YDir','normal')
subplot 122
surf(xvv, yvv, power,'EdgeColor', 'none','FaceColor','interp')
When measuring, important parts were measured in detail due to time issues, but other parts were measured at 3mm intervals.
The yellow part is the part where the yellow part is 0 in the part measured at 3mm intervals, and I want to get a code that fills the yellow part between the circles using interpolation.
please.

Antworten (1)

Chunru
Chunru am 18 Jul. 2023
load(websave("power.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1436568/power.mat"))
whos
Name Size Bytes Class Attributes cmdout 1x33 66 char power 401x401 1286408 double
L2 = 200;
unitstep = 1;
% xv = (unique([L2:-unitstep:0,0:-unitstep:-L2],'stable')); % +L/2 부터 -L/2 까지 unit-step 행렬생성
% yv = (unique([L2:-unitstep:0,0:-unitstep:-L2],'stable')); % -L/2 부터 +L/2 까지 unit-step 행렬생성
xv = unique(0:400,'stable'); % +L/2 부터 -L/2 까지 unit-step 행렬생성
yv = unique(0:400,'stable'); % -L/2 부터 +L/2 까지 unit-step 행렬생성
[X, Y] = meshgrid(xv,yv);
F_mesh = [X(:),Y(:)]; % 1열 행렬로 변환
Nf = size(F_mesh,1);
xvv = xv; yvv = yv;
Nx = numel(xvv); Ny = numel(yvv);
figure(1)
subplot 121
imagesc(xvv,yvv,power);
axis equal
xlim([0 400])
ylim([0 400])
set(gca,'YDir','normal')
subplot 122
surf(xvv, yvv, power,'EdgeColor', 'none','FaceColor','interp')
figure
subplot(121)
power1 = power;
power1(power1 > -0.2) = "nan";
power2 =fillmissing2(power1, "natural");
imagesc(xvv,yvv,power2);
axis equal
xlim([0 400])
ylim([0 400])
set(gca,'YDir','normal');
subplot(122)
surf(xvv, yvv, power2,'EdgeColor', 'none','FaceColor','interp')

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by