我想了解电影在Matlab是如何工作的,我从来没有使用过它。我有用于查找下段I决定把物体(杆)的长度的量的热传导方程的码。我能够绘制正常不过的情节,显示在不同条件下所有的值。我在左外野试图了解如何将它变成一部电影。
A=0.1; %Diffusivity or conductivity (switching for variable K)
L=1; %Length of rod
dt= 10^(-4); %value of timestep
X=100; %Wants to Discretize rod into 100 separate sections
t= 10; % 50 timesteps will be taken (dt)
dx=L/X; %delta X needed for the heat equation for this case Pi/100
x1=linspace(0, L, X); %Take 100 equally spaced sections between 0 and L
y1=linspace(0, t, 51);
T1= zeros(X,t); %set a X x t matrix of zeros
%Set boundary and initial conditions
%T0=0; Ends of rod temperature are 0
%TL=0;
%Create a for loop to continuously solve the heat equation until time is up
for i= 2:X-1 %X-1 because we already know initial point
for j=1:50 % used to update heat equation each step
T1(:,1)= sin((pi*x1(i))/L);%start solving the heat equation at second
% value in the matrix in column 1 (skip
% 1st because we have initial condition)
T1(1,:) = 0; %Gives the first column = 0
T1(100,:) = 0; %Gives last column = 0 just as initial conditions state
%Heat Equation for T^n+1 (i)
T1(i,j+1)= A*dt*((T1(i+1,j)-2*T1(i,j)+T1(i-1,j)/dx^2))+ T1(i,j);
end
end
figure(1)
plot(x1,T1);
任何意见将是巨大的。我已经看了几个不同的例子来自其他国家的人民后,但他们似乎都没有进入电影一样。 qazxsw POI
需要你有一系列RGB图像的存储器中,并且它们被存储在被设计为movie
功能结构的阵列。
你可以做的是在情节与movie
一次一个信号。此外,您还可以使用hold on
实际捕捉每一个积成的图像来获得所需要的格式getframe
,这一切都连接成一个结构数组,最后播放影片。
我看到你绘制所有信号的每个信号一列同时。为了简单起见,使通过每个单独信号中的另一movie
回路和循环 - 每列一个,绘制这些一次一个。
for
新代码将存储所需的情节一样的图像 - 你必须看到这个数字,以便绘制虽然对于要抓住框架。在那之后,我们关闭这个数字在5 FPS播放影片。在此之后,你只需要运行最后A=0.1; %Diffusivity or conductivity (switching for variable K)
L=1; %Length of rod
dt= 10^(-4); %value of timestep
X=100; %Wants to Discretize rod into 100 separate sections
t= 10; % 50 timesteps will be taken (dt)
dx=L/X; %delta X needed for the heat equation for this case Pi/100
x1=linspace(0, L, X); %Take 100 equally spaced sections between 0 and L
y1=linspace(0, t, 51);
T1= zeros(X,t); %set a X x t matrix of zeros
%Set boundary and initial conditions
%T0=0; Ends of rod temperature are 0
%TL=0;
%Create a for loop to continuously solve the heat equation until time is up
for i= 2:X-1 %X-1 because we already know initial point
for j=1:50 % used to update heat equation each step
T1(:,1)= sin((pi*x1(i))/L);%start solving the heat equation at second
% value in the matrix in column 1 (skip
% 1st because we have initial condition)
T1(1,:) = 0; %Gives the first column = 0
T1(100,:) = 0; %Gives last column = 0 just as initial conditions state
%Heat Equation for T^n+1 (i)
T1(i,j+1)= A*dt*((T1(i+1,j)-2*T1(i,j)+T1(i-1,j)/dx^2))+ T1(i,j);
end
end
figure(1)
hold on; % New
% New - To store the frames for the movie
frames = repmat(struct('cdata', [], 'colormap', []), 50, 1);
for j = 2 : 51
plot(x1,T1(:,j));
frames(j - 1) = getframe(gcf);
end
close all; % Close the figure
% Play the movie
figure;
movie(frames, 1, 5); % Play the movie once at 5 frames per second
命令你喜欢玩电影多次。第二个参数指定你想多少次电影重复第三个参数指定每个电影的第二帧。