フィルターのクリア

how get min value of three dimensional data?

4 ビュー (過去 30 日間)
Vedanta
Vedanta 2024 年 3 月 21 日
コメント済み: Vedanta 2024 年 3 月 21 日
Hello everyone,
I have a 3d matrix, Data = 125X135X144. here 125X135 is lat X lon and 144 is time.
I want to get the min and max matrix for every 4months. so that the output will bet, out = 125X135X36
the below code is working for nansum but not nanmin function is showing some error.
z = reshape(Data,129,135,4,[ ]);
x = nansum(z,3); % sum over every season
y = squeeze(x);
After getting the min max matrix, I need to substract the first min value of out time series from the first 4months of Data time series then second min value from the next 4month like that it will be done. so that the Final output will be 125X135X144
I hope my question is clear.
Thanks

採用された回答

Dinesh
Dinesh 2024 年 3 月 21 日
Hi Vedanta,
I did not get any error while using the "nanmin" function. My code is as follows:
% Generating Sample Data
Data = rand(125, 135, 144) * 100;
DataReshaped = reshape(Data, 125, 135, 4, []);
minMatrix = zeros(size(DataReshaped, 1), size(DataReshaped, 2), size(DataReshaped, 4));
for i = 1:size(DataReshaped, 4)
minMatrix(:, :, i) = nanmin(DataReshaped(:, :, :, i), [], 3);
end
% After getting the min matrix
FinalOutput = zeros(size(Data));
for i = 1:size(DataReshaped, 4)
for j = 1:4
monthIndex = (i-1)*4 + j;
FinalOutput(:, :, monthIndex) = Data(:, :, monthIndex) - minMatrix(:, :, i);
end
end
disp(FinalOutput);
Please let me know if this is not what you are looking for and I will take a look at this again.
  1 件のコメント
Vedanta
Vedanta 2024 年 3 月 21 日
thanks @Dinesh it is working.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime Series Events についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by