# Loop for contour a 3 inputs function

2 vues (au cours des 30 derniers jours)
stamos dontas le 12 Jan 2021
Commenté : stamos dontas le 12 Jan 2021
Hello ,
Suppose i have
function(s)=abc(x,y,z)
e.g. s= x.^2+2x.*y.*z+y^3+y.^2+5*z.^3+5*z
x1=rand(1000);
y1=rand(1000);
z1=rand(1000)
n=length(z1);
And i want for every z1=(1:n)
z1(n)=z
e.g. if the first z (z=1) I would like a contour of the function
s1= x.^2+2x.*y.*z+y^3+y.^2+5z.^3+5*1+5
contourf(x1,y1,s1). I want to do this for all z1 and i dont care defining the2 inputs functionsi care only for the contours
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

KSSV le 12 Jan 2021
x = linspace(-1,1) ;
y = linspace(-1,1) ;
z = linspace(-1,1) ;
[x,y,z] = meshgrid(x,y,z) ;
s = x.^2+2*x.*y.*z+y.^3+y.^2+5*z.^3+5*z ;
% Use slice
xslice = [-1 0 +1];
yslice = 0.;
zslice = 0;
slice(x,y,z,s,xslice,yslice,zslice)
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
stamos dontas le 12 Jan 2021
perfect man it works but i also need to store each one of those contours or just to pop up after the script. Now the 3d version appears. I want each one 2 d contour

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by