How do I create a sphere without sphere function that will inflate like a balloon utilizing the getframe function?

조회 수: 4 (최근 30일)
I have a basic code set for movement of a string that I would like to follow suit with a sphere inflating from an arbitrary initial radius (R_0) to an end radius (R_F):
clear String u x
c = 1.0; % wave equation constant
k = 0.5; % maximum initial string deflection
L = 1.0; % length of string
N = 3; % number of Fourier sine terms
M = 501; % number of movie frames, each corresponding to a specific time
TT = 5.0; % total time
x = [0.000:0.01:1.00]';
hold off
for T = 1:1:M
t = (T - 1) * (TT / (M - 1));
u = zeros(size(x));
for n = 1:1:N
lambdan = c * n * pi / L;
bn = (8 * k / (n^2 * pi^2)) * sin(n * pi / 2);
u = u + bn * cos(lambdan * t) * sin(n * pi * x / L);
end
plot(x,u,'LineWidth',6,'Color','green')
xlim([0.0 1.0])
ylim([-0.5 0.5])
String(:,T) = getframe;
end
movie(String,1,60)
How can I set this coding above to suit my purposes for a sphere? Again, not utilzing the Sphere function that exists in matlab.
Thank you

답변 (1개)

darova
darova 2019년 11월 12일
Use surf to create a 3D surface
rr = linspace(0,0.5,20);
tt = linspace(0,2*pi,40);
[R,T] = meshgrid(rr,tt);
[X,Y] = pol2cart(T,R);
for
% ...
z = interp1(x-0.5,u,rr);
[Z,~] = meshgrid(z,tt);
surf(X,Y,Z)
pause(0.05)
end
  댓글 수: 4
Zjuv9021
Zjuv9021 2019년 11월 20일
I essentially would like to obtain a visualization of a sphere inflating in 3D space.
darova
darova 2019년 11월 20일
Can you make a simple drawing or something? How it should looks like?

댓글을 달려면 로그인하십시오.

카테고리

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