Rotating data using griddata

6 次查看(过去 30 天)
ran
ran 2023-9-24
评论: Matt J 2023-9-25
I have a tmperature flow data abouve wall with a slop. I want to smooth the data on the wall so i rotated the data using griddata(). now i want to retern to the original palne so i tray the same thing but i get matrix of NaN. do griddata() work with matrixs? any way to fix it? in my code xn yn and Tn are the original data.
load Tdata5000
theta = -atan2(0.002, 0.005 ); % in degrees
% Calculate the rotated x and y coordinates element-wise
rotated_x = xn.* cos(theta) - yn.* sin(theta);
rotated_y = xn.* sin(theta) + yn.* cos(theta);
num_points = 1000; % Adjust this number as needed
uniqe_x = linspace(min(rotated_x(:)), max(rotated_x(:)), num_points);
uniqe_y = linspace(min(rotated_y(:)), max(rotated_y(:)), num_points);
[X, Y] = meshgrid(uniqe_x, uniqe_y);
% Interpolate the temperature data onto the grid
rotated_T = griddata(rotated_x, rotated_y, Tn, X, Y);
rotated_T = smoothdata(rotated_T,2,'movmean',35);
% Reverse the rotation by using the negative angle
reverse_theta = -theta;
% Calculate the rotated x and y coordinates element-wise
original_x = X .* cos(reverse_theta) - Y .* sin(reverse_theta);
original_y = X .* sin(reverse_theta) + Y .* cos(reverse_theta);
% Interpolate the rotated and smoothed data onto the original grid
original_T = griddata(X, Y, rotated_T, original_x, original_y,'cubic');
contourf(original_x, original_x, original_T)
Warning: Contour not rendered for non-finite ZData

回答(1 个)

Matt J
Matt J 2023-9-24
You should probably just use imrotate with the loose option flag.
  4 个评论
ran
ran 2023-9-25
编辑:ran 2023-9-25
i use 'cubic' intarpulation in 'griddata()' yes. when i use imrotate the adges of my data get wired, some of my data delleted when i rotate the data in the first place then when i tray to get back i ge exsta data where my data was befor how i fix that????? but i think using imrotate willl be much easer aproch then what i do now.
another problem i have with it that i cant use it to flip the image then flip it back beacuse for some reason it crate the problem again, so all i want to do it to flip it from the 'griddata()' back to the original results without any missing data
Matt J
Matt J 2023-9-25
Try using imrotate with cubic interpolation.

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by