フィルターのクリア

How do I construct a GUI?

1 回表示 (過去 30 日間)
james smith
james smith 2016 年 4 月 6 日
コメント済み: james smith 2016 年 4 月 6 日
How do I construct a GUI that can be used to animate a solution?

回答 (1 件)

Maneet Goyal
Maneet Goyal 2016 年 4 月 6 日
Hello:
Constructing a GUI in MATLAB can be done with the help of 'GUIDE' which stands for Graphical User Interface Design Environment. Simple type 'guide' (without the inverted commas) in the command window. A screen will pop up and I think you can take it from there. A lot of videos are available on YouTube covering the same.
I am not sure about the animation part. What I think is that animating a solution is done with the help of commands like 'pause' or 'drawnow'. Once you have created your GUI, you can upload the animation code onto the same. As and when the code runs, the output screen of your GUI will automatically display the solutions in motion. You can try running this function which I wrote for some assignment. It shows particles in Brownian (random) motion.
Hope it helps!
function Diffusion(N)
h = plot(0.5*ones(1,N/2),0.5*ones(1,N/2),'k.',-0.5*ones(1,N/2),0.5*ones(1,N/2),'r.');
xlim([-4 4]); % Width of the Plane
ylim([-4 4]); % Length of the Plane
xr1 = 0.5; yr1 = 0.0; % Initial Position of Black Particles
xr2 = -0.5; yr2 = 0.0; % Initial Position of Red Particles
for t = 1:1000 % No. of Iterations
xr1 = xr1 + 0.00009*randi([-1000 1000],1,N/2); yr1 = yr1 + 0.00009*randi([-1000 1000],1,N/2); % New Positions of Blacks
xr2 = xr2 + 0.00008*randi([-1000 1000],1,N/2); yr2 = yr2 + 0.00008*randi([-1000 1000],1,N/2); % New Positions of Reds
set(h(1), 'xdata',xr1,'ydata',yr1); % Feeding New Positions of Blacks to the Graph
set(h(2), 'xdata',xr2,'ydata',yr2); % Feeding New Positions of Reds to the Graph
pause(0.001); % Update figure window | Plots the new data
% Use this command if you are updating graphics objects in a loop and do not need to see every update
% on the screen.
end
end
  1 件のコメント
james smith
james smith 2016 年 4 月 6 日
thank you! :)

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by