How to plot a function depending on 3 different vectors as mesh or surface

2 次查看(过去 30 天)
hello How I can plot the function f as a mesh or surface thanks for any help
d = 0.1;
a = 0.7;
t1 = -20:1:20;
t2 = -20:1:20;
t3 = -20:1:20;
t4 = -20:1:20;
x = cosd(t1).*(d.* sind(t2+t3+t4)+a_2 .*cosd(t2)+a* cosd(t2+t3));
y = sind(t1).*(d.* sind(t2+t3+t4)+a_2 .*cosd(t2)+a.* cosd(t2+t3));
z = a.* sind(t2) - d.* cosd(t2+t3+t4) + a.* sind(t2+t3) ;
f = sqrt(x.^2 + y.^2 + z.^2);

采纳的回答

KSSV
KSSV 2018-8-7
d = 0.1;
a = 0.7; a_2 = 0.9 ;
t1 = -20:1:20;
t2 = -20:1:20;
t3 = -20:1:20;
t4 = -20:1:20;
x = cosd(t1).*(d.* sind(t2+t3+t4)+a_2 .*cosd(t2)+a* cosd(t2+t3));
y = sind(t1).*(d.* sind(t2+t3+t4)+a_2 .*cosd(t2)+a.* cosd(t2+t3));
z = a.* sind(t2) - d.* cosd(t2+t3+t4) + a.* sind(t2+t3) ;
[X,Y,Z] = meshgrid(x,y,z) ;
% f = sqrt(x.^2 + y.^2 + z.^2);
F = sqrt(X.^2 + Y.^2 + Z.^2);
figure
hold on
for i = 1:41
surf(X(:,:,i),Y(:,:,i),Z(:,:,i),F(:,:,i))
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by