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

2 views (last 30 days)
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);

Accepted Answer

KSSV
KSSV on 7 Aug 2018
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!