the contours are not coming in the plot

3 views (last 30 days)
MADHVI
MADHVI on 9 May 2024
Commented: Pratyush Swain on 15 May 2024
In this code, the contourslice line is not running. It's showing index in position 1 is invalid. Array indices must be positive integers or logical avalues.
I am not able to get the contour in the figure.
D_value = 0.1;
L_value = 0.1;
B_value = 0.1;
x = 0:0.01:L_value/D_value;
y = 0:0.01:B_value/D_value;
z = 0:0.01:1;
%[Y, X, Z] = meshgrid(y, x, z);
[X,Y,Z] = meshgrid(x,y,z);
%lvls = 0.1:0.01:0.2
% xmin = min(x(:));
% xmax = max(x(:));
% ymax = max(y(:));
% zmin = min(z(:));
%[sx,sy,sz] = meshgrid(x,y,z);
Ra_value = 70;
%xi = 0.3;
xi = 0.25;
R_value = Ra_value*xi;
% A1_1_1 = -7.5303;
% A1_1_2 = -1.6340;
% A1_2_1 = 0.8963;
% A1_2_2 = -0.5867;
% A2_1_1 = -0.3891;
% A2_1_2 = -0.7100;
% A2_2_1 = 0.0256;
A1_1_1 = -6.8611;
A1_1_2 = -1.5016;
A1_2_1 = 0.8252;
A1_2_2 = -0.5324;
A2_1_1 = -0.2012;
A2_1_2 = -0.5086;
A2_2_1 = 0.0171;
% a1 = sin(pi.*Z);
% a2 = sin(2.*pi.*Z);
% a3 = cos(pi.*D_value.*X./L_value);
% a4 = cos(pi.*D_value.*Y./B_value);
f = @(X,Y,Z) (pi^2.*A1_1_1.*sin(pi.*Z) + (pi^2+(pi^2.*D_value^2/B_value^2)).*A1_1_2.*sin(pi.*Z).*cos(pi.*D_value.*Y/B_value) + (pi^2+(pi^2.*D_value^2/L_value^2)).*A1_2_1.*sin(pi.*Z).*cos(pi.*D_value.*X/L_value) +(pi^2+(pi^2.*D_value^2/B_value^2)+(pi^2.*D_value^2/L_value^2)).*A1_2_2.*sin(pi.*Z).*cos(pi.*D_value.*X/L_value).*cos(pi.*D_value.*Y/B_value) + 4.*pi^2.*A2_1_1.*sin(2.*pi.*Z) + (4.*pi^2+(pi^2.*D_value^2/B_value^2)).*A2_1_2.*sin(2.*pi.*Z).*cos(pi.*D_value.*Y/B_value) + (4.*pi^2+(pi^2.*D_value^2/L_value^2)).*A2_2_1.*sin(2.*pi.*Z).*cos(pi.*D_value.*X/L_value) )/R_value;
%f = @(X,Y,Z) (pi^2.*A1_1_1.*a1 + (pi^2+(pi^2.*D_value^2./B_value^2)).*A1_1_2.*a1.*a4 + (pi^2+(pi^2.*D_value^2./L_value^2)).*A1_2_1.*a1.*a3 +(pi^2+(pi^2.*D_value^2./B_value^2)+(pi^2.*D_value^2./L_value^2)).*A1_2_2.*a1.*a3.*a4 + 4.*pi^2.*A2_1_1.*a2 + (4.*pi^2+(pi^2.*D_value^2./B_value^2)).*A2_1_2.*a2.*a4 + (4.*pi^2+(pi^2.*D_value^2./L_value^2)).*A2_2_1.*a2.*a3 )./R_value;
colormap(turbo)
hx1 = slice(X,Y,Z,f(X,Y,Z),x(100),[],[]);
hx1.FaceColor = 'interp';
hx1.EdgeColor = 'none';
%rotate(hx1,[1 0 0],45)
colorbar;
hold on
hx2 = slice(X,Y,Z,f(X,Y,Z),[],y(100),[]);
hx2.FaceColor = 'interp';
hx2.EdgeColor = 'none';
%rotate(hx2,[0 0 1],45)
colorbar;
hx3 = slice(X,Y,Z,f(X,Y,Z),[],[],z(1));
hx3.FaceColor = 'interp';
hx3.EdgeColor = 'none';
%rotate(hx1,[0 0 1],25)
colorbar;
% hx4 = slice(X,Y,Z,f(X,Y,Z),[],[],z(25));
% hx4.FaceColor = 'interp';
% hx4.EdgeColor = 'none';
% colorbar;
contourslice(X,Y,Z,f(X,Y,Z),[],[],z(100));
% hx5 = slice(X,Y,Z,f(X,Y,Z),[],[],z(100));
% hx5.FaceColor = 'interp';
% hx5.EdgeColor = 'none';
colorbar;
contourslice(X,Y,Z,f(X,Y,Z),x(10),[], [])
contourslice(X,Y,Z,f(X,Y,Z),[],y(10), [])
contourslice(X,Y,Z,f(X,Y,Z),[],[],z(10))
%contourslice(X,Y,Z,f(X,Y,Z),[xmin, 100, xmax],ymax,zmin);
view(3)
%slice(X,Y,Z,f(X,Y,Z),(x(1)+x(end))/2,[],[]);
%contourslice(X,Y,Z,f(X,Y,Z),(x(1)+x(end))/2,[],[])
%streamline(x,y,z,X,Y,Z,sx,sy,sz)
%isosurface(Z,X,Y, f(Z,X,Y));
% isosurface(Y, X, Z, f(Y,X,Z));
% FaceColor;
colorbar;
% shading flat;
%(Y(:,:,1), X(:,:,1)); %squeeze(I(:,:,1)));%remove single dimension
xlabel('x');
ylabel('y');
zlabel('z');
  3 Comments
Torsten
Torsten on 9 May 2024
Edited: Torsten on 9 May 2024
Click the "Edit" button, change whatever you like in the code and click "Run" to execute.
Pratyush Swain
Pratyush Swain on 15 May 2024
Since I notice you already have the above code running fine on MATLAB, can you pinpoint where exactly are you facing the error ? Also the commented lines are adding to the confusion.
Thanks

Sign in to comment.

Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!