Need help in plotting the 3 variable function's contour
Afficher commentaires plus anciens
clc
clear all
close all
% format long
step = 10;
z = linspace(0,1.2e-6,step);
x = linspace(-0.1e-6,0.1e-6,step);
y=linspace(-0.1e-6,0.1e-6,step);
%r=sqrt(x.^2+y.^2);
z1 = 1e-6;
L = 9.995498999999999e-07;
a1 = 8.999974099901931e-10;
s = linspace(-L,L,1e5);
F0 = 3.15e7;
Mat_V = zeros(length(z),length(x),length(y));
for i = 1 : length(z)
i
for j = 1 : length(x)
for k= 1:length(y)
if abs(sqrt(x(j).^2+y(k).^2)) > sqrt((a1*z1)*(1-(z(i)*z(i)/z1/z1)))
F_f = s ./((sqrt(x(j).^2+y(k).^2) + (z(i)-s).^2).^0.5);
V_f = @(z,F_f) F0 * z1 / (z1 * log((L+z1)/(-L+z1)) - 2 * L) * (trapz(s,F_f)) - F0 * z;
Mat_V(i,j,k) = V_f(z(i),F_f);
else
Mat_V(i,j,k) = 0;
end
end
end
end
[X,Y,Z] = ndgrid(x,y,z) ;
F =Mat_V(Z,X,Y) ;
figure
hold on
for i = 1:100
surf(X(:,:,i),Y(:,:,i),Z(:,:,i),F(:,:,i)) ;
end
axis([-3 3 -3 3]);grid minor
view(3);
shading interp
%set(gca,'FontSize',25,'fontweight','bold')
%size = 35;
%xlabel('X ({\mu}m)','FontSize',size,'fontweight','bold')
%ylabel('Z ({\mu}m)','FontSize',size,'fontweight','bold')
%axis equal
2 commentaires
Walter Roberson
le 22 Juil 2022
Mat_V(i,j,k) = V_f(z(i),F_f);
That is an array assignment with integer indices.
F =Mat_V(Z,X,Y) ;
That is an attempt to index the array with non-integer indices. Perhaps you want to use permute()?
Yasir Iqbal
le 22 Juil 2022
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



