フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Error in determining MIN and MAX values from a given vector

1 回表示 (過去 30 日間)
Rahul
Rahul 2024 年 4 月 9 日
閉鎖済み: Stephen23 2024 年 4 月 9 日
Hi,
From the attached data my intention is to determine the min and max values for pressure.
Thus in data.variable.pressure the highest value is at the left (center) which decreases as we go to the right (pedestal).
The max and min value of central pressure is to be captured and similarly the max and min pressure for pedestal pressure is also to be captured.
However my code is unable to differentiate between the two effectively.
It captures both Avg_Pressure_cen and Avg_Pressure_ped as 1.8619, which is not correct.
Similarly it is also unable to capture the pressure gradient correctly.
Thus need your suggestion for the code as below.
rowx1 = 1;
rowx2 = 100;
rowt1 = 90;
rowt2 = 100;
tstep=100; xstep=100;
Pressure_ped=zeros(tstep,xstep);
Pressure_cen=zeros(tstep,xstep);
Density_ped=zeros(tstep,xstep);
Density_cen=zeros(tstep,xstep);
turbulenceintensity_ped=zeros(tstep,xstep);
turbulenceintensity_cen=zeros(tstep,xstep);
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);
% disp('change_x=')
% disp(change_x)
if change_x >= 0.1
disp(j)
width(i)=1-data.variable.x(j);
%disp(width)
X_pedped(i) = gP(i);
end
end
end
%disp('X_pedped=')
%disp(X_pedped)
Index_ped = find(X_pedped~=0);
%disp(Index_ped)
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 abs(gDensity_ped(j-1)) < abs(gDensity_ped(j)) & abs(gDensity_ped(j)) < abs(gDensity_ped(j+1))
gDensity_ped_MAX(j) = gDensity_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)

回答 (0 件)

この質問は閉じられています。

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by