Clear Filters
Clear Filters

Error while extracting MIN and MAX values from a given data

1 view (last 30 days)
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
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081 0.9091 1.0101 1.1111 1.2121 1.3131 1.4141 1.5152 1.6162 1.7172 1.8182 1.9192 2.0202 2.1212 2.2222 2.3232 2.4242 2.5253 2.6263 2.7273 2.8283 2.9293 3.0303 3.1313 3.2323 3.3333 3.4343 3.5354 3.6364 3.7374 3.8384 3.9394 4.0404 4.1414 4.2424 4.3434 4.4444 4.5455 4.6465 4.7475 4.8485 4.9495 5.0505 5.1515 5.2525 5.3535 5.4545 5.5556 5.6566 5.7576 5.8586 5.9596 6.0606 6.1616 6.2626 6.3636 6.4646 6.5657 6.6667 6.7677 6.8687 6.9697 7.0707 7.1717 7.2727 7.3737 7.4747 7.5758 7.6768 7.7778 7.8788 7.9798 8.0808 8.1818 8.2828 8.3838 8.4848 8.5859 8.6869 8.7879 8.8889 8.9899 9.0909 9.1919 9.2929 9.3939 9.4949 9.5960 9.6970 9.7980 9.8990 10
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);
Unrecognized function or variable '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
VBBV on 9 Apr 2024
Check if the conditions used are correct for extracting MIN,MAX & AVG values for those variables,

Sign in to comment.

Answers (1)

Aman
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!

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!