MATLAB Answers

Zjuv9021
0

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

Zjuv9021
さんによって質問されました 2019 年 11 月 12 日 2:05
最新アクティビティ darova
さんによって コメントされました 2019 年 11 月 20 日 10:22
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

  0 件のコメント

サインイン to comment.

タグ

1 件の回答

回答者: darova
2019 年 11 月 12 日 10:29

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 件のコメント

darova
2019 年 11 月 16 日 19:18
You want to plot a sphere or plot your curve in 3D (surface)?
Zjuv9021
2019 年 11 月 20 日 0:37
I essentially would like to obtain a visualization of a sphere inflating in 3D space.
darova
2019 年 11 月 20 日 10:22
Can you make a simple drawing or something? How it should looks like?

サインイン to comment.



Translated by