0% found this document useful (0 votes)
21 views12 pages

Matlab App Designer

The document outlines the steps to design a user interface for a MATLAB app, including the organization of data in Excel and the creation of callback functions. It details how to read data from an Excel file, process it to find specific properties based on temperature inputs, and display results in the app. Additionally, it emphasizes the importance of setting input constraints and saving the app appropriately.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Matlab App Designer

The document outlines the steps to design a user interface for a MATLAB app, including the organization of data in Excel and the creation of callback functions. It details how to read data from an Excel file, process it to find specific properties based on temperature inputs, and display results in the app. Additionally, it emphasizes the importance of setting input constraints and saving the app appropriately.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

0 Designing the user Interface


• With the knowledge obtained in lecture 1&2, design the user
interface as shown in the question.
• NOTE!
• The EditField labeled “Temperature”, and the listbox labeled “Physical
Properties” are grouped into a Penel titled “Data”.
• And the Axes/graph labeled “SPP Vs Temperature” alongside with the
EditField labeled ‘SPP” are also grouped into another Panel titled “Results”
• With the graph, select Axes at the top right corner of the component
library.
• The ButtonPush labeled “Run” is under the panel labeled “Data”
1.0 Designing the user Interface cont’d

To be able to follow the


lecture easily, Make sure your
labelling tally with the one in
fig 1.0.

After designing the interface,


creat a callback Function for
the Run button.

Fig 1.0 The user interface of the app


2.0 Organizing The data in Exel
• In the question, the
fist step is asking as
to create an exel file
for the data.
• Open Ms Exel, and
write the data as
shown in fig 1.2.
• After that, save it in
the same folder in
which you saved the
matlab app.
Fig 1.2 Physical Properties Data
2.0 Reading the data into matlab
Under the created callback
function, read the exel file
into a table form title “data”.
This can be done by writing
this code. Note, “Book1” is
the name inwhich the file
was saved, and the “.xlsx” is
the file extention. Replace
this with the name inwhich
you save your file
2.0 Reading the data into matlab cont’d

After runing, the code, this is how the data will be read into the workspace; However, this comes with the warning below it,
and this is beacause, the properties in the exel file are “Density(Kg/m3), Viscosity(mpa-s), Cp(KJ/Kg-K)” which were changed to
the above. This can be corrected by reading the table as “data=readtable(‘Book.xlsx’, ‘VariableNamingRule’, ‘preserve’). But
lets use the modified(properties) form as in the figure above
3.0 Transforming The Task into a Code

After reading, the table, we assign the properties to some


letters as shown in the figure. The app then checks the
see the property specified, suppose the specified
property is “Density(Kg/m3)”, it then checks to see if the
temperature values(T) in the table contains a value
exactle as the specified temperature(Ti), this is than
using “if any(Ti==T). if there’s any, then it the fetch its
corrsponding Density at that Temperature using
“f=interp1(T, V, Ti)” and display it in the “SPP Editfile”.
Repeating the above procedure for the rest of the
properties will meet the above requirement.
3.0 Transforming The Task into a Code Cont’d

• After that, run the code, and


specify a temperature, say 50
and any of the “Physical
Properties” then click on the
“Run button” to display the
corresponding “SSP Value”.
3.0 Transforming The Task into a Code Cont’d

if the “T” doesn’t contain a value exactly as the specified “Ti”, the
app then use “input_temp” to make sure the Ti is in the T range(1 -
90) . It then estimate the index of that value(Ti), mostly 2 using “idx”,
and extract the T range(temp_range) in which that value falls, by
taking the immidiate T values above and below it as the Tmin with
index (idx) 1 and Tmax with index 3. Using “Spp_range” to take their
corresponding property values and interpolate (f) to get the SPP
value. finally, it displays it on the SPP edit field. Repeating the above
procedure for the rest of the properties will meeet the requirements
above. Note, the “interp1” is an inbuild matlab funtion that works
exactly as the eqution provided in the question.
3.0 Transforming The Task into a Code Cont’d

• The last part is asking us to pot the Temperature against


the selected properties. This can be done using the plot
function in the figure. And it can be repeated for the rest
3.0 Transforming The Task into a Code Cont’d

The above are the codes in the case of


Viscosity and Cp
• After everything, you can run the app, specify any
of the conditions and click on the Run button to
display your results.
• Note, with the previous knowledg, set the SSP field
to be uneditable and the Temperature field to take
only inputs in the range of 1 to 90.
• Save your app as matlapp app or standalone
desktop app
THAT WILL BE ALL FOR NOW, SEE YOU IN THE
NEXT TUTORIAL.

THANK YOU

You might also like