Filter löschen
Filter löschen

Error during contour plot

8 Ansichten (letzte 30 Tage)
Rahul am 5 Apr. 2024
Kommentiert: Rahul am 6 Apr. 2024
While trying to generate a contour plot, I'm getting an error which is thown as
"The size of X must match the size of Z or the number of columns of Z."
while the size of my X (i.e. H0) and Z (i.e. I0) is same, I can't find why is the error thrown.
rowx1 = 1;
rowx2 = 100;
rowt1 = 1;
rowt2 = 100;
xstep = 100;
tstep = 100;
X_pedped = 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));
for i = 2:rowx2
if abs((2*abs(gP(i-1)-gP(i))/(gP(i-1)+gP(i)))*100) > 90
X_pedped(i) = gP(i);
Index_ped = find(X_pedped~=0);
gPressure_ped = abs(data.variable.gradpressure(rowt1:rowt2));
Pressure_ped = abs(data.variable.pressure(rowt1:rowt2));
Density_ped = abs(data.variable.density(rowt1:rowt2));
turbulenceintensity_ped = abs(data.variable.turbulenceintensity(rowt1:rowt2));
Pressure_cen = abs(data.variable.pressure(rowt1:rowt2,1));
Density_cen = abs(data.variable.density(rowt1:rowt2,1));
turbulenceintensity_cen = abs(data.variable.turbulenceintensity(rowt1:rowt2,1));
for i = rowt1:rowt2
Flowshear_p(i-rowt1+1,1) = mean(abs(data.variable.wexb_p(i,1:end)));
Flowshear_n(i-rowt1+1,1) = mean(abs(data.variable.wexb_n(i,1:end)));
tstep = rowt2-rowt1+1;
Fs= 1/T;
p_cen = Pressure_cen;
Y = fftshift(fft(p_cen));
L = length(Y);
Ynew = 2*abs(Y(2:length(Y)/2-1)/L);
f = Fs*(0:L/2-3)/L;
Ynew_NA = Ynew/max(Ynew);
[value, index] = max(Ynew(:,1));
Frequency = f(1,index);
for j = 2:rowt2
if j < rowt2
if Pressure_cen(j-1) < Pressure_cen(j) && Pressure_cen(j) > Pressure_cen(j+1)
Pressure_ped_MAX(j) = Pressure_ped(j);
Density_ped_MAX(j) = Density_ped(j);
turbulenceintensity_ped_MAX(j) = turbulenceintensity_ped(j);
Flowshear_p_MAX(j) = Flowshear_p(j);
Flowshear_n_MAX(j) = Flowshear_n(j);
Pressure_cen_MAX(j) = Pressure_cen(j);
Density_cen_MAX(j) = Density_cen(j);
turbulenceintensity_cen_MAX(j) = turbulenceintensity_cen(j);
Time_MAX(j) = Time(j);
if gPressure_ped(j-1) < gPressure_ped(j) && gPressure_ped(j) > gPressure_ped(j+1)
gPressure_ped_MAX(j) = gPressure_ped(j);
if Pressure_cen(j-1) > Pressure_cen(j) && Pressure_cen(j) < Pressure_cen(j+1)
Pressure_ped_MIN(j) = Pressure_ped(j);
Density_ped_MIN(j) = Density_ped(j);
turbulenceintensity_ped_MIN(j) = turbulenceintensity_ped(j);
Flowshear_p_MIN(j) = Flowshear_p(j);
Flowshear_n_MIN(j) = Flowshear_n(j);
gPressure_ped_MIN(j) = gPressure_ped(j);
Pressure_cen_MIN(j) = Pressure_cen(j);
Density_cen_MIN(j) = Density_cen(j);
turbulenceintensity_cen_MIN(j) = turbulenceintensity_cen(j);
Time_MIN(j) = Time(j);
if gPressure_ped(j-1) > gPressure_ped(j) && gPressure_ped(j) < gPressure_ped(j+1)
gPressure_ped_MIN(j) = gPressure_ped(j);
%---------------------------- 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);
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 ; Chi1 D0 D1;Avg_Flowshear_p Avg_Flowshear_n 0 ];
%-------------------------------Contour data H0 vs I0-------------------------------------
H0I0_Pressure_cen = [H0_27bi_001(2,1) H0_27bi_002(2,1) H0_27bi_003(2,1) H0_27bi_004(2,1) H0_27bi_005(2,1) H0_27bi_006(2,1) H0_27bi_007(2,1) H0_04bi_008(2,1);
H0_01bi_009(2,1) H0_01bi_010(2,1) H0_02bi_011(2,1) H0_03bi_012(2,1) H0_04bi_013(2,1) H0_05bi_014(2,1) H0_12bi_015(2,1) H0_12bi_016(2,1);
H0_15bi_017(2,1) H0_17bi_018(2,1) H0_21bi_019(2,1) H0_12bi_020(2,1) H0_12bi_021(2,1) H0_12bi_022(2,1) H0_12bi_023(2,1) H0_12bi_024(2,1)];
H0I0_Density_cen = [H0_27bi_001(2,2) H0_27bi_002(2,2) H0_27bi_003(2,2) H0_27bi_004(2,2) H0_27bi_005(2,2) H0_27bi_006(2,2) H0_27bi_007(2,2) H0_04bi_008(2,2);
H0_01bi_009(2,2) H0_01bi_010(2,2) H0_02bi_011(2,2) H0_03bi_012(2,2) H0_04bi_013(2,2) H0_05bi_014(2,2) H0_12bi_015(2,2) H0_12bi_016(2,2);
H0_15bi_017(2,2) H0_17bi_018(2,2) H0_21bi_019(2,2) H0_12bi_020(2,2) H0_12bi_021(2,2) H0_12bi_022(2,2) H0_12bi_023(2,2) H0_12bi_024(2,2)];
H0I0_Pressure_ped = [H0_27bi_001(1,1) H0_27bi_002(1,1) H0_27bi_003(1,1) H0_27bi_004(1,1) H0_27bi_005(1,1) H0_27bi_006(1,1) H0_27bi_007(1,1) H0_04bi_008(1,1);
H0_01bi_009(1,1) H0_01bi_010(1,1) H0_02bi_011(1,1) H0_03bi_012(1,1) H0_04bi_013(1,1) H0_05bi_014(1,1) H0_12bi_015(1,1) H0_12bi_016(1,1);
H0_15bi_017(1,1) H0_17bi_018(1,1) H0_21bi_019(1,1) H0_12bi_020(1,1) H0_12bi_021(1,1) H0_12bi_022(1,1) H0_12bi_023(1,1) H0_12bi_024(1,1)];
H0I0_Density_ped = [H0_27bi_001(1,2) H0_27bi_002(1,2) H0_27bi_003(1,2) H0_27bi_004(1,2) H0_27bi_005(1,2) H0_27bi_006(1,2) H0_27bi_007(1,2) H0_04bi_008(1,2);
H0_01bi_009(1,2) H0_01bi_010(1,2) H0_02bi_011(1,2) H0_03bi_012(1,2) H0_04bi_013(1,2) H0_05bi_014(1,2) H0_12bi_015(1,2) H0_12bi_016(1,2);
H0_15bi_017(1,2) H0_17bi_018(1,2) H0_21bi_019(1,2) H0_12bi_020(1,2) H0_12bi_021(1,2) H0_12bi_022(1,2) H0_12bi_023(1,2) H0_12bi_024(1,2)];
H0I0_Pressure_cen2 = smoothdata(H0I0_Pressure_cen); % adapt the smoothing amount to your needs...
H0I0_Density_cen2 = smoothdata(H0I0_Density_cen); % adapt the smoothing amount to your needs...
H0I0_Pressure_ped2 = smoothdata(H0I0_Pressure_ped); % adapt the smoothing amount to your needs...
H0I0_Density_ped2 = smoothdata(H0I0_Density_ped); % adapt the smoothing amount to your needs...
H00 = 4:1:13;
I00 = 7:-0.5:5;
[H0,I0] = meshgrid(H00,I00);
Attached is the code and data file.
  1 Kommentar
Star Strider
Star Strider am 5 Apr. 2024
Please describe what you want to do. Most of the fileds in ‘data.variable’ are (100x100) matrices, so they would be usable in a contour plot. None of the variables after the ‘Contour data H0 vs I0’ comment are defined in your posted code.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 5 Apr. 2024

the first parameter to contourf is the x data, which corresponds to columns. the second parameter to contourf is y data which corresponds to rows

Weitere Antworten (0)


Mehr zu Contour Plots finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by