Error while extracting MIN and MAX values from a given data
1 view (last 30 days)
Show older comments
Hi,
While trying to extract the min and max values from a given data, the code is unable to extract correctly for data.variable.pressure.
In this data, the values are gradually decreasing from left (represents the cen) to right (represents the ped).
The max and min values are to be extracted separately both for cen and ped as Avg_pressure_min and Avg_pressure_max.
However the code is unable to do so and gives single value as 1.8619 for both cen and ped.
Also, it is unable to do so for pressure gradient.
Hence need your valuable suggestion.
% Edited to run here
load data1_H0_27b.mat
rowx1 = 1;
rowx2 = 100;
rowt1 = 90;
rowt2 = 100;
Time = data.variable.t(1,rowt1:rowt2);
gP = data.variable.gradpressure(end,:);
Normalized_pressure_gradient = gP./abs(min(gP));
x = data.variable.x(1,rowx1:rowx2);
for i = 1:length(data.variable.x)-1
percentage_difference_gP(i) = abs(Normalized_pressure_gradient(end,i+1)-Normalized_pressure_gradient(end,i))*200/abs(Normalized_pressure_gradient(end,i+1)+Normalized_pressure_gradient(end,i));
end
for i=1:max(length(data.variable.t))
disp(data.variable.t(i))
for j=1:max(length(data.variable.x))-1
change_x = (data.variable.gradpressure(i,j+1)-data.variable.gradpressure(i,j))/data.variable.gradpressure(i,j);
if change_x >= 0.1
% disp(j)
width(i)=1-data.variable.x(j);
X_pedped(i) = gP(i);
end
end
end
Index_ped = find(X_pedped~=0);
gPressure_ped = abs(data.variable.gradpressure(rowt1:rowt2));
Pressure_ped = abs(data.variable.pressure(rowt1:rowt2));
gPressure_cen = abs(data.variable.gradpressure(rowt1:rowt2,1));
Pressure_cen = abs(data.variable.pressure(rowt1:rowt2,1));
for j = 2:rowt2-rowt1+1
if j < rowt2-rowt1+1
if Pressure_cen(j-1) < Pressure_cen(j) & Pressure_cen(j) > Pressure_cen(j+1)
Pressure_ped_MAX(j) = Pressure_ped(j);
Pressure_cen_MAX(j) = Pressure_cen(j);
end
if gPressure_ped(j-1) < gPressure_ped(j) & gPressure_ped(j) < gPressure_ped(j+1)
gPressure_ped_MAX(j) = gPressure_ped(j);
end
if Pressure_cen(j-1) > Pressure_cen(j) & Pressure_cen(j) < Pressure_cen(j+1)
Pressure_ped_MIN(j) = Pressure_ped(j);
gPressure_ped_MIN(j) = gPressure_ped(j);
Pressure_cen_MIN(j) = Pressure_cen(j);
end
if gPressure_ped(j-1) > gPressure_ped(j) & gPressure_ped(j) < gPressure_ped(j+1)
gPressure_ped_MIN(j) = gPressure_ped(j);
end
end
end
%---------------------------- data calculation ----------------------------
check_Hmode_percentage_difference_gP = max(percentage_difference_gP);
Avg_Pressure_ped = mean(Pressure_ped);
Avg_Density_ped = mean(Density_ped);
Avg_turbulenceintensity_ped = mean(turbulenceintensity_ped);
Avg_Pressure_cen = mean(Pressure_cen);
Avg_Density_cen = mean(Density_cen);
Avg_turbulenceintensity_cen = mean(turbulenceintensity_cen);
Avg_Flowshear_p = mean(Flowshear_p);
Avg_Flowshear_n = mean(Flowshear_n);
Avg_heatflux_cen = mean(heatflux_cen);
Avg_particleflux_cen = mean(particleflux_cen);
Avg_heatflux_ped = mean(heatflux_ped);
Avg_particleflux_ped = mean(particleflux_ped);
H0 = abs(data.constant.H0);
S0 = abs(data.constant.S0);
Chi0 = abs(data.constant.chi0);
Chi1 = abs(data.constant.chi1);
D0 = abs(data.constant.D0);
D1 = abs(data.constant.D1);
H0_12bi_024 = [Avg_Pressure_ped Avg_Density_ped Avg_turbulenceintensity_ped; Avg_Pressure_cen Avg_Density_cen Avg_turbulenceintensity_cen;
H0 S0 Chi0 ; D0 D1 Chi1;Avg_Flowshear_p Avg_Flowshear_n 0
Avg_heatflux_cen Avg_particleflux_cen 0; Avg_heatflux_ped Avg_particleflux_ped 0];
%disp(H0_12bi_024)
1 Comment
VBBV
on 9 Apr 2024
Check if the conditions used are correct for extracting MIN,MAX & AVG values for those variables,
Answers (1)
Aman
on 23 Apr 2024
Hi Rahul,
From the description, I understood that you want to extract the left most (cen) and the right most (ped) values from the data and want to know their averages, respectively.
In the current implementation, it will give the same value as the below code, which gives the same value array, which is the leftmost.
Pressure_ped = abs(data.variable.pressure(rowt1:rowt2));
Pressure_cen = abs(data.variable.pressure(rowt1:rowt2,1));
In order to get your desired result, you can make the below changes in order to fetch the ped and cen values, respectively.
Pressure_ped = abs(data.variable.pressure(rowt1:rowt2,end));
Pressure_cen = abs(data.variable.pressure(rowt1:rowt2,1));
I hope it works for you!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!