MENGM 1411 Computer Based Modelling & Graphical User Interfaces Discussion

MENGM1411: Computer Based Modelling.MATLAB GUI. Find the attached files

MENGM1411: Computer Based Modelling
5. Parametric design project
Andrew Harrison
andrew.j.l.harrison@bristol.ac.uk
Room 2.12 Queens Building
1
Parametric design and interface with a
rapid prototype machine

Parametric design is the generation of geometry from the
definition of:
a
group of initial parameters
 the relations between the parameters


This hierarchy of mathematical and geometric relations will
allow you to generate a certain design
Aims of this project
 Develop
an ‘interesting’ geometric form of your choosing
 Generate an .stl file that contains appropriate details of the design (stl
file may be used to interface with rapid prototype machine)
2
Example: Desk fan (M. Alaleeli, L. Chen, 2016)
3
Example: Wheel rim(T. Streuli, O. Schiffmann, 2019)
4
Project tasks

Develop a simple algorithm that receives input and displays
the design on screen
A
Graphically User Interface (GUI) is the preferred method for doing
this

Develop or modify (as appropriate) a function that writes an
‘.stl’ output file
 There



are currently functions available in MATLAB
https://uk.mathworks.com/matlabcentral/fileexchange/20922-stlwrite-filename-vararginhttps://uk.mathworks.com/matlabcentral/fileexchange/36770-stlwrite-writebinary-or-ascii-stl-file
Extend the complexity of your parametric design object
5
Assessment

Final project (100%) – Parametric design
 Submission
of a zip file containing all your MATLAB code
 Submission of your report, pdf file (maximum 7 sides) on Blackboard Deadline: 07/05/21 by 11:59a.m. Assessors will not consider and assess
anything you wrote above the page limit
 All submissions are checked against plagiarism!
 Viva examination (10 min) – 13-14/05/21
6
Marking criteria

Code (60%)

Performance







Aesthetics




Presentation of results / use of graphics as appropriate
Program structure – use of indentation, functions…
Sensible variable names
Report (40%)


Does the program run?
Are the results correct?
Does the program complete all the required aspects of the project?
‘User Friendliness’ (GUI)
Brevity / Speed of execution
Suggestions for improvement and development of the project
Follow the report template available on Blackboard
Note: Your final mark will depend on the level of complexity of the object you choose
to design as well as the functionality of your code
7
A simple example of parametric
design…
8
Centre hole radius
Collar width
Main outer radius
Collar height
Teeth length
Gear thickness
Number of teeth
0
−5
0
−5
−10
−10
−15
−15
9
Example code outline
% Input parametric data, .e.g.
number_teeth = 30; centre_hole_radius = 1; collar_width = 1;
main_outer_radius = 5; collar_height =0.5; teeth_length = 1;
gear_thickness = 1;
% calculate dependencies: e.g.
collar_radius = centre_hole_radius + collar_width;
teeth_outer_radius = main_outer_radius + teeth_length;
% Create an object that can be manipulated into a gear
% Hint: use the in-built cylinder function to create (x,y,z) points
% Output
% 1) Plot the gear in 3D
% 2) Save the geometry data to a .stl file: hint use stlwrite e.g.
Where to start?


Start with the preliminary exercise on Blackboard
Understand how to create


A gear (pdf files available on Blackboard)
Multiple gears

Develop from here in incremental stages

Guidelines

Planning: divide the project into several smaller manageable task (e.g. functions), each of
which should not contain more than around 50 lines
 Writing: Adopt a ‘top down’ approach – write the main body first, then the detailed tasks.
Use meaningful variable names.
 Debugging: Consult the staff as well as the online help (values of global variables can be
checked using the workspace browser, line-by-line step) It is important that you can
demonstrate that your software generates correct results
 Improving: use the Profiler tool to identify the lines in your code that take the most time to
execute and then look for ways to speed them up. Where possible eliminate for loops – try
instead to operate on an entire array in one command (vectorisation)
11
Today 11-12/03/2021

By now, you should have:
 Completed the preliminary exercise (how to create a gear) – Solution
available on Blackboard soon

Now:
 Complete the tutorial about how to create a GUI using AppDesigner
12
MENG11511: Computer Based Modelling
Preliminary exercise for the Parametric
Design project
Irene Renaud-Assemat
ir14333@bristol.ac.uk
Room 2.26
1
Part A

Create a figure window

Generate x, y, z, coordinates of a
cylinder with a radius equal to 3

Draw a wireframe mesh

Display a three-dimensional plot of
the points on the same graph
2
Part B

Create a figure window

Generate x, y, z, coordinates of a
cylinder with a radius equal to 5 and
100 equally spaced points around its
circumference

Draw a wireframe mesh

Display a three-dimensional plot of the
points on the same graph
3
Part C

Create a figure window

Generate x, y, z, coordinates of a shape
with 𝑟1 = 1 and 𝑟2 = 2 (as shown on the
figure) and 100 equally spaced points
around its circumference

Draw a wireframe mesh

Display a three-dimensional plot of the
points on the same graph
4
Part D

Create a figure window

Generate x, y, z, coordinates of an object with






𝑟1 = 1
𝑟2 = 1
𝑟3 = 1
𝑟4 = 4
𝑟5 = 5
and 100 equally spaced points around its circumference

Draw a wireframe mesh

Display a three-dimensional plot of the points on the
same graph
5
Part E

Create a full cylinder
 Radius
=1
 Height = 1
6
Part F

Create a hollow cylinder
 Inner
radius = 2
 Outer radius = 3
 Height = 1
7
Part G

Create this object
Collar
Centre
width hole radius
Main outer radius
Collar
height
 Centre
hole radius = 1
 Collar width = 1
 Main outer radius = 5
 Collar height = 0.5
 Gear thickness = 1
Gear
thickness
8
Part H

Create a gear from
the previous geometry
Teeth length
 Teeth
length = 1
 Number of teeth = 30
9
Parametric Design Program
Object you chose to design
Your name: Your user ID (e.g. AB12345)
Your name: Your user ID (e.g. AB12345)
Abstract (maximum 1/3 page)
The abstract is a summary of your entire report, including motivation, aims, main findings, and
conclusions. The abstract is not just a repetition of the Introduction. It should be a stand-alone
document that someone could read to get an overview. You should write this section last.
1. Introduction (maximum 1/2 page)
The Introduction explains the motivation behind the topic to the reader. This should include
both general (or ‘big picture’) background information, and more detailed information relative
to your project. External references can be used if appropriate. The objectives (or aims or
purpose) of this study should be clearly stated.
2. Pseudocode / Flow chart (maximum 2 pages)
Describe the main structure of your program using pseudocodes and/or flow charts.
3. Major challenges (maximum 2 pages)
3.1 E.g. Designing the geometry from the definition of parameters
3.2 E.g. Generating an .stl file
3.3 E.g. Developing the Graphical User Interface (GUI)
3.4 E.g. Optimising the program
4. Running the code (maximum 1 page)

How do I run your code?
What should I see when your code runs? (Show screen shots of your working code
as figures with appropriate captions)
Are there any special issues?
1
5. Conclusion (maximum ½ page)
In this section you should concisely present the most important findings, which should relate
to your original objectives. You can also summarise what was done and any recommendations
for future work. There should not be any new information in this section.
References
Provide the details of any sources referenced. Use a standard citation format, e.g. the Harvard
referencing system.
Mark scheme
This provides a guide to the mark scheme:
– Report should be formal, maximum 7 sides
– Marked report will be available to see on Blackboard 3 weeks after submission
– Marks are available for presentation, content, quality of writing, standard of tables
and figures, and depth of understanding
Section
Percentage mark
Abstract
15%
Introduction
10%
Pseudocode / Flow
chart
20%
Major challenges
25%
Running the code
15%
Conclusion
10%
References
5%
Teaching support: Irene Renaud-Assemat (ir14333@bristol.ac.uk)
2
MENG11511: Computer Based Modelling
How to create a GUI using AppDesigner
Solution
Irene Renaud-Assemat
ir14333@bristol.ac.uk
Room 2.26
1
AppDesigner Online tutorial

Create and run a simple App using App
Designer
 Run
the tutorial by entering this command
in the MATLAB Command Window
>>appdesigner.internal.application.openTutorial(‘BasicCoding’)
 Follow
the steps
2
Create a GUI for the gear example

In the Matlab command window enter the command
>> appdesigner to launch AppDesigner

Drag the components you need from the
Component Library onto the canvas (Design View)

To insert a picture, select a Button component, and
in the Button properties > More Properties, browse
your image
3

Click Code View to edit the code

Declare the global variables
(variables that are accessible to all
functions and callbacks in the app)
 Define
a Private Property
 Edit
the properties block (you can
specify default values)
 To
use the variable elsewhere in your
code, use app.variable_name notation
4

In the code view, add a callback function for each edit field
(numeric) component
 Right-click
app.variable_nameEditField in the Component
Browser
 Select
Callbacks > Add ValueChangedFcn callback
 Repeat
for each input variable
5

Create a callback for the button to generate
the geometry on the screen

Write down the code to generate the geometry

Plot the geometry (the target axis is required
as the first argument)
E.g. mesh(app.UIAxes, app.x, app.y, app.z)

Create a callback for the button to create an
stl file

Write down the appropriate code
6

AppDesigner does not support interactive functionality such
as mouse callback to 3-D rotate a figure, here is a solution to
overcome this issue:
 Create
a Toggle Switch on your canvas
 In
the callback function, use the function rotate3d to rotate your
figure when the switch is on
7

Run the code and check that everything is
working as expected

Correct display of the geometry

Change of the input parameters

3D-rotation view

Generation of an stl file, check that your file is
correct using a free online STL viewer
(https://www.viewstl.com)
8
Desk_fan
Desk Fan
6
4
Base shape
Cylinder
Diameter
Thickness
2
EL
4
N
Pole shape
Diameter
1.5
Cylinder
Height
15
20
12
18
1
12
16
14
13
Blade shape
Cambered
Length
Thickness
1.2

12
10
0.8
10
10
0.8
8
6
No. of blades
6
4
?
2
8
6
Stl. file (Whole)
0
2
Generate
Reset
2.
Stl.file (Parts)
0
-2
-8
Desk_fan
Desk Fan
6
4
Base shape
Cylinder
Diameter
Thickness
2
4
N
Pole shape
Diameter
1.5
Cylinder
Height
15

20
12
18
1
12
16
14
Blade shape
Length
13
Cambered
Thickness
1.2

12
10
0.8
10
10
0.8
8
6
No. of blades
6
4
2
8
6
Stl.file (Whole)
2
Generate
Reset
Stl.file (Parts)
-2
-8

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, how can I help?