how get min value of three dimensional data?

5 次查看(过去 30 天)
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time Series Events 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by