How to do interploation ARGO data?
1 次查看(过去 30 天)
显示 更早的评论
My data is about ARGO float. I use PRES, TEMP, PSAL. All of this data are 1017 x 16 double size, Dimension is DEPTH, TIME. I want to use interp1 by using Pi = 0:10:2000; T = interp1(PRES, TEMP,Pi) and S = interp1(PRES, TEMP, Pi) but i can't do interp1 because of NaN and duplicative values.
file = '*.nc';
ncdisp(file);
TEMP = ncread(file,'TEMP');
PRES = ncread(file,'PRES');
SALI = ncread(file,'PSAL');
TIME = ncread(file,'TIME');
LON = ncread(file,'LONGITUDE');
LAT = ncread(file,'LATITUDE');
Pi = 0:10:2000;
T = interp1(PRES,TEMP,Pi);
S = interp1(PRES,SALI,Pi);
My Png is data of PRES. Please help me....
2 个评论
Angelo Yeo
2023-9-20
질문해주신 내용만으로는 데이터가 어떻게 문제인지 정확히 판단하기 어렵습니다. 데이터를 공유해주시면 답변 받는데 도움이 될 수 있을 것 같습니다.
또, 데이터를 정리할 필요가 있습니다. NaN을 처리하기 위해서 NaN이 들어있는 데이터 원소를 모두 0으로 치환하거나 아래와 같은 툴로 missing data를 채워넣는 과정이 우선시 되어야 할 것 같습니다.
回答(1 个)
Vinayak
2024-1-4
Hi ESES
I believe you're looking to replace NaN (Not a Number) values with 0 and also want to eliminate any duplicate entries in your dataset. Additionally, as Angelo Yeo has pointed out, you might consider estimating values to fill in those gaps, depending on the context of your data and the importance of maintaining its integrity.
Below, I've provided a sample code snippet that accomplishes the replacement of NaN values with 0 and the removal of duplicates. You can adapt this code to fit the specific needs of your project:
% Read Data, I have created a random data set
% Replace NaN values with zeros in TEMP, PRES, and SALI
TEMP(isnan(TEMP)) = 0;
PRES(isnan(PRES)) = 0;
SALI(isnan(SALI)) = 0;
% Find unique rows based on the combination of PRES, TEMP, and SALI
data = [PRES, TEMP, SALI];
[uniqueData, ~] = unique(data, 'rows');
% Extract unique PRES, TEMP, and SALI values
pres = uniqueData(:, 1);
temp = uniqueData(:, 2);
sali = uniqueData(:, 3);
% Define the desired pressure levels for interpolation
Pi = 0:10:2000;
% Interpolate TEMP and SALI at the desired pressure levels Pi
% For demonstration, we'll just interpolate one profile
T = interp1(pres, temp, Pi, 'linear', 0); % 'linear' interpolation and extrapolation with 0
S = interp1(pres, sali, Pi, 'linear', 0);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!