Computing 3d plot with three AxBxC arrays

Hi All,
I am working on a project and I have computed data like given in the code below. If the data is 2 by 2, I can get a 3d graph, but my data are 3 dimensional. I want to get a graph in which the first axis is 'Qx' the second 'Qy' and the third one should be 'ed' or 'Ax'. Please check out the code, you will understand what I meant. Any help will be appreciated. Thanks in advance.
Best regards,
OA
% cift for loop ile meshgrid komutu yazildi. Cooooookkk Onemlliiiii
% As=Lx/Ly % Aspect ratio of the building
% Lx=35
% Ly=[1:3:100];
% As=Lx./Ly
j=1;
k=1;
l=1;
Lx=1;
Ly=1;
Ax=1;
As=1;
e=0;
for Ax=0.7:0.1:3;
for Qx=0:0.1:2.5;
for Qy=0:0.1:2.5;
edx(k,j,l)=(((Qy*(sqrt(((As^-2+1)*(Lx)^2)/12)+e))^2)/Lx)*((1.2*(Ax^0.5)-1)/(0.6*(Ax^0.5)));
edy(k,j,l)=(((Qx*(sqrt(((As^2+1)*(Ly)^2)/12)+e))^2)/Ly)*((1.2*(Ax^0.5)-1)/(0.6*(Ax^0.5)));
ed(k,j,l)=sqrt(edx(k,j).^2+edy(k,j).^2);
Axx(k,j,l)=Ax;
QQx(k,j,l)=Qx;
QQy(k,j,l)=Qy;
Axx(k,j,l)=Ax;
k=k+1;
end
k=1;
j=j+1;
end
j=1;
l=l+1;
end
figure (3)
surf(QQx,QQy,Axx);
xlabel('Qx');
ylabel('Qy');
zlabel('Accidental eccentricity (m)'); % burasinin Accidental eccentricity olmasinin sebebi e=0 olarak almamizdan kaynaklanmaktadir.
% shading interp
colorbar
figure (4)
contour(QQx,QQy,Axx,30);
xlabel('Qx');
ylabel('Qy');
zlabel('Accidental eccentricity (m)'); % burasinin Accidental eccentricity olmasinin sebebi e=0 olarak almamizdan kaynaklanmaktadir.
% shading interp
colorbar

4 comentarios

You can only plot 2D matrices with surf and contour. Here I simply ‘stacked’ the surf plots. You can do something similar with the contour plots, although they will likely have to be plotted in different figures, however the matrices are constant here so the contour plots will not be drawn.
j=1;
k=1;
l=1;
Lx=1;
Ly=1;
Ax=1;
As=1;
e=0;
for Ax=0.7:0.1:3;
for Qx=0:0.1:2.5;
for Qy=0:0.1:2.5;
edx(k,j,l)=(((Qy*(sqrt(((As^-2+1)*(Lx)^2)/12)+e))^2)/Lx)*((1.2*(Ax^0.5)-1)/(0.6*(Ax^0.5)));
edy(k,j,l)=(((Qx*(sqrt(((As^2+1)*(Ly)^2)/12)+e))^2)/Ly)*((1.2*(Ax^0.5)-1)/(0.6*(Ax^0.5)));
ed(k,j,l)=sqrt(edx(k,j).^2+edy(k,j).^2);
Axx(k,j,l)=Ax;
QQx(k,j,l)=Qx;
QQy(k,j,l)=Qy;
Axx(k,j,l)=Ax;
k=k+1;
end
k=1;
j=j+1;
end
j=1;
l=l+1;
end
figure (3)
% QQx
% QQy
% Axx
hold on
for k = 1:size(Axx,3)
surf(QQx(:,:,k),QQy(:,:,k),Axx(:,:,k));
end
hold off
view(30,30)
xlabel('Qx');
ylabel('Qy');
zlabel('Accidental eccentricity (m)'); % burasinin Accidental eccentricity olmasinin sebebi e=0 olarak almamizdan kaynaklanmaktadir.
% shading interp
colorbar
figure (4)
for k = 1:size(Axx,3)
contour(QQx(:,:,k),QQy(:,:,k),Axx(:,:,k),30);
end
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
Warning: Contour not rendered for constant ZData
xlabel('Qx');
ylabel('Qy');
zlabel('Accidental eccentricity (m)'); % burasinin Accidental eccentricity olmasinin sebebi e=0 olarak almamizdan kaynaklanmaktadir.
% shading interp
colorbar
.
Osman AKYUREK
Osman AKYUREK el 22 de Ag. de 2023
Movida: Star Strider el 22 de Ag. de 2023
figure (3)
hold on
for k = 1:size(ed,3)
surf(QQx(:,:,k),QQy(:,:,k),ed(:,:,k));
end
hold off
view(30,30)
xlabel('Qx');
ylabel('Qy');
zlabel('Accidental eccentricity (m)'); % burasinin Accidental eccentricity olmasinin sebebi e=0 olarak almamizdan kaynaklanmaktadir.
% shading interp
colorbar
Osman AKYUREK
Osman AKYUREK el 22 de Ag. de 2023
Movida: Star Strider el 22 de Ag. de 2023
Thank you for your quick response. It works.
Star Strider
Star Strider el 22 de Ag. de 2023
My pleasure!
I did not post it as an Answer because I was not certain it was what you wanted, especially with respect to the contour plots (that cannot exist for constant matrices).

Iniciar sesión para comentar.

 Respuesta aceptada

Steven Lord
Steven Lord el 22 de Ag. de 2023

0 votos

Based on what Star Strider posted and looking at the Types of MATLAB Plots page in the documentation (which is also available in a slightly different form in the Plots tab in the Toolstrip) it seems like slice or contourslice or perhaps contour3 will be of use to you. [The isosurface function should probably be in this list as well, in the Volume Visualization or Contour Plots sections. I'll note that to the documentation staff.]

Más respuestas (0)

Etiquetas

Preguntada:

el 22 de Ag. de 2023

Respondida:

el 22 de Ag. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by