Error with contourf representing 3d plot in 2d

1 vue (au cours des 30 derniers jours)
Kevin Hanekom
Kevin Hanekom le 14 Août 2021
Commenté : Kevin Hanekom le 15 Août 2021
Good afternoon,
I have been trying to compile a contour surface of my 3d object in the sig1-sig2 space (X-Y). When compiling it shows as an error and im not sure why.
Heres the code
clc; clear;
sig1c = .35031092712186400;
sig1t = .35031092712186400; %.39026571574305700
sig2c = sig1c;
sig2t = sig1t;
% sig3c = .56181805055156500;
% sig3t = .02333758968994630;
sig3c = sig1c; %will reduce to von misses if sig1t = sig1c
sig3t = sig1t;
tau23 = .07; %sheer strenth, tau23 is symetric with tau13
tau13 = tau23;
tau12 = .23;
F1 = ((1/sig1t)-(1/sig1c));
F2 = ((1/sig2t)-(1/sig2c));
F3 = ((1/sig3t)-(1/sig3c));
F11 = (1/(sig1c*sig1t));
F22 = (1/(sig2c*sig2t));
F33 = (1/(sig3c*sig3t));
F44 = (1/(tau23^2));
F55 = (1/(tau13^2));
F66 = (1/(tau12^2));
F12 = -0.5*sqrt((F11*F22)); %only defines a range for F12, complete determination for orthotropic materials still needs to be resolved.
F13 = -0.5*sqrt((F11*F33));
F23 = -0.5*sqrt((F22*F33));
syms sig1 sig2 sig3 G
[sig1,sig2,sig3] = meshgrid(linspace(-2,2,100));
sig1b = 0;
sig2b = 0;
sig3b = 0;
Data = sqrt(sig1.^2+sig2.^2+sig3.^2);
G = F1.*sig1 + F11.*sig1.^2 + F2.*sig2 + F22.*sig2.^2 + F3.*sig3 + F33.*sig3.^2 + (2*F12.*sig1.*sig2) + (2*F13.*sig1.*sig3) + (2*F23.*sig2.*sig3) - 1;
%G = F1.*sig1 + F11.*sig1.^2 + F2.*sig2 + F22.*sig2.^2 + F3.*sig3 + F33.*sig3.^2 + F44.*tau23.^2 + F55.*tau13.^2 + F66.*tau12.^2 + (2*F12.*sig1.*sig2) + (2*F13.*sig1.*sig3) + (2*F23.*sig2.*sig3) - 1;
G(G>1) = 1;
tiledlayout(1,2)
nexttile
Stich = patch(isosurface(sig1,sig2,sig3,G,0));
isonormals(sig1,sig2,sig3,G,Stich)
isocolors(sig1,sig2,sig3,Data,Stich)
colormap(turbo(9))
shading interp
% Stich.FaceColor = 'interp';
% Stich.EdgeColor = 'black';
xlabel("\sigma_1 (GPa)");
ylabel("\sigma_2 (GPa)");
zlabel("\sigma_3 (GPa)");
title('Tsai-Wu Ultimate Yield Surface');
view(3);
axis padded
grid on
colorbar
nexttile
[sig1,sig2] = contourf(G)
Error using contourf (line 55)
Input arguments must have at most 2 dimensions.
Sorry for the long intro, but as you can see the problem is at the last line of the code.
Thank you for the time,
Kevin

Réponse acceptée

Simon Chan
Simon Chan le 15 Août 2021
Refer to the MATLAB documentation in this Link
contourf(X,Y,Z) specifies the x and y coordinates for the values in Z.
However, varaiable G is a 3-dimensional matrix and hence it gives an error.
Assume you would like to add all the values in the 3rd dimension, you can sum them up, create a matrix H and replace the last line with the following lines. You can obtain the attached figure.
contourf(linspace(-2,2,100),linspace(-2,2,100),H);
axis equal
colorbar
xlabel("\sigma_1 (GPa)");
ylabel("\sigma_2 (GPa)");
title('Sum up z-dimension data');
Noticed that I don't have the Symbolic Math Toolbox and hence skips the following line when running the code
syms sig1 sig2 sig3 G
  1 commentaire
Kevin Hanekom
Kevin Hanekom le 15 Août 2021
This is amazing! Thank you for clearing this up for me. Ill implement the same thing for sig1-sig2, sig2-3 now aswell.
Thanks again!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Preprocessing dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by