MATLAB Answers

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

5 ビュー (過去 30 日間)
Zjuv9021
Zjuv9021 2019 年 11 月 12 日
コメント済み: darova 2019 年 11 月 20 日
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 件のコメント

サインインしてコメントする。

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

表示 1 件の古いコメント
darova
darova 2019 年 11 月 16 日
You want to plot a sphere or plot your curve in 3D (surface)?
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?

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by