Engineering 132 exam study guide
Engineering 132 exam study guide 132
verified elite notetaker
verified elite notetaker
verified elite notetaker
verified elite notetaker
verified elite notetaker
verified elite notetaker
Popular in Engineering and Tech
This 42 page Study Guide was uploaded by Nikki Bee on Thursday June 25, 2015. The Study Guide belongs to 132 at Purdue University taught by in Spring 2015. Since its upload, it has received 318 views. For similar materials see in Engineering and Tech at Purdue University.
Reviews for Engineering 132 exam study guide
Better than the professor's notes. I could actually understand what the heck was going on. Will be back for help in this class.
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 06/25/15
EXAM 3 STUDY GUIDE REVIEW ALL LECTURE SLIDES EAS OLINE MODULES ONLINE LOAS amp HOMEWORK MATLAB Logic Statements True or False those are your options MATLAB has 2 and only 2 possible results for logic statements False O or false True 1 and all other numbers other than 0 or true MATLAB Relational Operators Relational operators making your computer think Comparison operators compare 2 and only 2 values lt Less than lt Greater than lt Less than or equal to gt Greater than or equal to Not Equal to Equal to Builtin MATLAB commands any Checks if any elements in each column are true nonzero Returns 0 if all elements are false zero Code 1 gtgt A 6 O 1 5 gtgt anyA ans 1 Code 2 gtgt B 0 O O gtgtany B ans O all Checks if allelements in each column are true nonzero Returns 0 if one or more elements are false zero Code 1 gtgt A 6 2 15 gtgt allA ans 1 Code 2 gtgt B 6 2 O 15 gtgt allB ans O nd Returns the indices addresses of all nonzero elements or the results of relational operations Code1 gtgtA082450019 gtgt ndA ans 234589 Code 2 gtgt ndA gt 4 ans 259 MATLAB Logical Operators Logical operators connect logical statements AND amp is True if and only if all are true OR is True if and only if at least one is true Exclusive OR xor is True if and only if one is true NOT is True if false MATLAB follows the following order of operations 1 is rst and 12 is the last thing that is looked at in evaluating logical statements from httpwwwmathworkscomhelptechdocmatlabprogfO40063html 1 Parentheses 2 Transpose 39 power quot complex conjugate transpose 39 matrix power A 3 Unary plus unary minus logical negation 4 Multiplication right division left division matrix multiplication matrix right division I matrix left division 5 Addition subtraction H 6 Colon operator 7 Less than lt less than or equal to lt greater than gt greater than or equal to gt equal to not equal to 8 Elementwise AND amp 9 Elementwise OR YOU CANNOT USE INBETWEEN LOGIC IN MATLAB I 5lt Xlt1O CANNOT do in MATLAB I 5ltX amp X lt10 MUST do this in MATLAB Truth tables the lies cannot hide from the Truth Table Truth tables show all possible combinations of your logical expression to check to see if you are using correct logic Truth table for A and B A amp Truth table for A or B A B B Example of solving a logical statement A B A amp B A B A I B a2 lt 50ampb5gt 20cgt50 1 1 1 1 1 1 Whena25 b20 c30 1 0 0 1 0 1 252 lt 50amp105gt 2030gt50 O 1 O 0 1 1 50 lt 50amp15gt 20II30gt50 trueampfalsetrue falsetrue Truth table for A X0r B Truth Table for Not A A true X0rAB A A X0rAB 1 0 0 0 1 1 Ol tl tjgt l tOl kbd 1 Understanding data Summarizing data Measures of central tendency 1 Mean is the measure of the center of mass of the data It provides a good summary of the data however is effected by outliers Formula Excel for a data set in cell A1 to A24 AVERAGE A1A24 MATLAB for a data set called X meanofx meanX 2 Median is the middle 50 percentile of the data The Median is not effected by outliers and when the data is symmetric Mean equals Median Formula Sort the data and nd the middle value if there is even number of data points take the average to the middle 2 data points Excel for a data set in cell A1 to A24 MEDIAN A1A24 MATLAB for a data set called X medianofx medianX 3 Mode is the most common number In some data sets there are more than one mode Formula Find the number that appears most frequently Excel for a data set in cell A1 to A24 MODE A1A24 MATLAB for a data set called X modeofx modeX Measures of Dispersion 1 Standard deviation is a measure of how much the data varies from the mean Formula 71 2 Z xi mean 1 Standard devatlon 1 n Excel for a data set in cell A1 to A24 STDEV A1A24 MATLAB for a data set called X standarddeviationofx stdX 2 m is the largest value in a data set Formula Find the largest number Excel for a data set in cell A1 to A24 MAX A1A24 MATLAB for a data set called X maxofx maxX 3 Min is the smallest value in the data set Formula Find the smallest number Excel for a data set in cell A1 to A24 MIN A1A24 MATLAB for a data set called X minofx minX 4 Range is the measure of how far apart the smallest value and largest value are Formula Range Max Min Excel for a data set in cell A1 to A24 MAXA1A24 MNA1A24 MATLAB for a data set called X rangeofx rangeX EXCEL Histograms HISTOGRAMS a plot of the frequency of data in certain ranges called bins l Emel hi steps Imrt data Sort data from 1 to teat Find the number of bina EQRTf data inta Find width of Eh bin MESH EQRTdata pointajj Crate 111nm of upper bin values Bin Ran Fill in hiatogram dialog h t 3 You have a hiatal39 o Interpret The values on the bin labels are the upper most values of each bin right bin edge MATLAB Histograms 0 Creating histmyData creates a histogram with 10 centers histmyData20 creates a histogram with 20 centers histmyData clocation creates a histogram with centers already de ned by the vector clocation 1 Interpret The values on the bin labels are the center values of each bin If the histogram looks like a bell than the data is normally distributed Look to see if the data is skewed favoring one side over the other Look or any patterns in the graph or notable points l rm EEH l li d Distribution Standard Pmb bilit l th bili f approximate Deviations i Within i St Dutaicle i St Hum here from Mean Dev Outside of 5551 Flange quotI 0532553 031 E1 1 in 3 E UHE CID455 quotI in 22 3 UBEWSEI DUUEETI quotI in SET 4 1993534 DUUDUE quotI 1153 5 UBEEEIBEl DUUDUUDUE E in 10 E DEEEEIEIEEEIE UDUDUDDUDE E in 1 IIIg o If a data distribution is approximately normal then about 68 percent of the data values are within one standard deviation of the mean mathematically u i o where u is the arithmetic mean about 95 percent are within two standard deviations u i 20 and about 997 percent lie within three standard deviations u i 30 This is known as the 689599 rule or the empirical rule Teaming More People More Ideas Better Results What is a team A team is a small group of people with complementary skils who are committed to a common purpose performance goals and approach for which they hold themselves mutualy accountable Explain why engineers work in teams and how diverse perspectives are critical for designproblem solving Individuals working alone are usually ineffective in solving current complex engineering problems instead well trained multidisciplinary teams can address complex problems more productively Even simple things like electric tooth brushes are surprising complex The New Your Times reports in 1999 quotAn average electronic toothbrush has 3000 lines of computer codequot 1 Bet you didn t know that List and describe three basic tools at your disposal to improve your team s effectiveness Establish norms for your team develop a Code of Cooperation Sets a norm for acceptable and expected behavior for each team member and represents how the team members will interact with one another Recognize the ve stages of teaming development 1 Forming orientation Tentative polite on best behavior quotgetting to know youquot phase 2 Storming con ict Criticism poor attendance hostility polarization coalition forming If your team is stuck at this level seek facilitation 3 Norming cohesion Employing and establishing rules role de nition more we 4 Performingperformance Optimal stage actually accomplishing tasks and learning Decision Making problemsolving mutual cooperation task orientation 1 Hafner Katie quotHoney I Programmed the Blanketquot New York Times 27 May 1999 Retrieved from httpwwwr1ytimescom1 999052 7technologyhor1eyiprogrammed theblankethtm1pagewantedallampsrcpm 5 Adjourning dissolution List of team roles Recorder Responsible for writing notes during the group meeting Encourager Gatekeeper Responsibility of maintaining balanced levels of participation for all team members They will encourage the silent team members and try to hold back the verbose dominant team members Timekeeper Responsibility for keeping track of time as well as keeping the team moving so that they can nish the task at hand Meeting Coordinator Coordinates activities monitors the decision making process IMPORTANT This person is NOT THE BOSS Teaming Tips tools to make your team more effective not covered in FYE Classes Cloud Base Storage select one for you team Create a shared folder on with cloud base storage solution with service such as Dropbox wwwdropboxcom Google Drive drivegooglecom or SugarSync httpwwwsugarsynccom Cloud based storage gives every team member access to the latest versions of your team s les without needing to send thousands of emails Group Messaging Effective communication between team members is a necessity for having effective teams To insure effective communications set up a group messaging system There are many ways to do this The key is to select the tools that will work best for your team 1 Email Have a rule that all group emails must be sent to all people 2 Group Texting Texting is one of the most used forms of communication for our generation Group Me httbsdroubmecom is a service that gives your team a phone number that will send every person a text when you text that number 3 Social Media Use IM and messaging features of your favor social media site to keep team members updated Find out when everyone is free to work Make sure that you know when team members are free during the week so you can have quick meetings during the day and not at midnight Your team can use this quotEasy Team Schedulerquot template on Google docs googOsxvg or whatever your team likes best MATLAB Variables What are variables Variables are arbitrary name that you give to some data that is stored in the computer to make programming easer The computer thinks that Force MassAcceeration Voltage Current Resistance and Price Quantity UnitPrice are all the same calculation because I named the variables differently we now have 3 equations that are used in very different applications dynamics electricity and accounting I like to think of variables as voodoo dolls for data thank you to BC Kwon Waqas Javed Dr Elmqvist Dr Yi for this analogy httpwwwyoutubecomwatchvxE2RcOzEU Variable naming rules I Variables are case sensitive Plato and plato are different I Variables must start with a letter 50cent is not acceptable variable I Variables can consist of letters digits and underscores I No symbols except for underscore Keha is not an acceptable variable I No spaces I Make sure a variable name is not a built in MATLAB function Booleans Booleans are the simplest type of data in MATLAB they have 2 possible values 1true xor 0false The primary uses of Booleans are the result of logic operators Scalar Numbers Scalar numbers are any single real or imaginary number such as 5 31415926 pi and any other number on the number line Myscalarva riable 5 Vectors Creating vectors Must start and end with brackets Row vectors use spaces or commas to separate columns 39 rowVectorl 1 5 9 6 or rowVectorZ 15 9 6 I rowVector3 startValue incrementValue endvalue 39 Vec4 0525 is the same Vec4 0 5 10 15 20 25 Column vectors use semicolons to separate rows 39 colVector 1536 Matrixes Creating Matrices 0 About the same as vectors I aMatriX15369876 Accessing parts of a matrix or vector 0 this is done through indexing O valueAtLocationRowCol aMatiXrowcol I aMatriX12 value is five 5 I aMatiXl returns the first Colum I aMatiXl returns the first row I row and col can be any Scalar or Vector values or variables STRINGS Strings store letters and words that your program can use In MATLAB you use single quotes to make a string MyString 39Matlab is fun Other MATLAB commands we used this semester who displays variables that are in current memory clear clears all variables from memory clc just clears Command Window does NOT erase variables currently in use clear X w clears just variables x and w from memory doc launches the help in MATLAB logz gives the natural log of z log10z gives the log of 2 dimensions load39cylinderdatanoheadertxt loads the numerical data from this le into a variable called dimensions NOTE single quotes fprintf The average volume for all the objects is O4f cmquot3 Avgvol plotanglesradsinofanges ro39 xlabel39Angle radians ylabel39Amplitude title39Sine Function grid on hold on displays the average of the volumes stored in a vector called Avgvol to 4 decimal places NOTE where the single quote ends plots the sine function vs radians using a red solid line with circle data markers NOTE single quotes the order in which the line type marker and color are entered does not matter gives title to Xaxis NOTE single quotes gives title to yaxis NOTE single quotes gives title to your plot puts gridlines on your plot holds the rst plot on when plotting two plots on the same set of axes puts a legend on your plot NOTE single quotes order corresponds to the order that the graphs were plotted legend39sine 39cosine plots a histogram with the number of histcyinderdia noofbins bins you told it to use frequency centers histcyinderdia noofbins Gives you the number of elements in each bin and the bin centers MATLAB Using variables Addition and subtraction MATLAB uses for addition and for subtraction because MATLAB is matrix based depending on what type of variable you use could result in different results aScalar xor bScalar is simple addition or subtraction aScalar xor aMatrix will add the scalar number to every number in the vector aMatriX xor aScalar will add the scalar number to every number in the vector aMatrix xor bMatriX only works if the vectorsMatrix are the same size and will addsubtract the numbers that are in the same position ie 1 2 34 5 6 5 7 9 Multiplication Division and Powers MATLAB doe s Liner Algebra multiplication and division by default which can produce unexpected results In FYE classes you will want to do element by element multiplication and division which is done by using a dot in front of the operator l aMatrix bMatix element by element multiplication works only if the matrixes are the same size aMatrix bMatix Liner Algebra multiplication do not use in FYE Classes cScaIaraMatix will work every time cScaIardScalar will work every time aMatrixcScalar will work every time cScaIaraMatrix will work every time aMatrix bMatix element by element division will work only if the matrixes are the same size aMatrix AbMatix element by element power will work only if the matrixes are the same size aMatrixquotcScaar correct cScaIardScaar works but not allowed in exams cScaIaraMatix works but not allowed in exams cScaIaraMatrix will cause an error unless you have a special matrix aMatrixAcScalar will cause an error unless you have a special matrix aMatrix quotbMatix will cause an error WHEN DOING CALCULATIONS MAKE SURE THE RESULTS YOU GET MAKE SENSE Builtin Functions Sometimes there are calculations that for whatever reason are too hard to insert manually every time you need to use them Luckily MATLAB Excel your calculator other programming languages have functions to allow you to easily do hard calculations For example instead of calculating the sine of an angle manually you can use the sine function sin SineOpri sin 2pi Note pi is a built in value of 31415926 The general form of a function that you will use in calculations is and you just use this as another variable functionName input Example sin5 x y25xe Cos3x In MATLAB would be y 25 expsin 5x cos 3x UserDe ned functions turns your script into a secret agents All functions start with the following line called function de nition line function output1 output2 outputn functionName inputl input2 inputn The word function Your outputs in square bracket I If you have 0 outputs leave this blank I If you have 1 output no commas are need I If you have gt1 outputs separate each output with a comma Your function name must be the same as your m file Your inputs are in parentheses Multiple inputs are separated with commas I To check to see if your User Defined Function is complete make sure that there are no squiggly lines under your inputs and outputs in the function definition line I The variables that are in the function definition line will be defined when someone calls the function I You must use a vector to call multiple outputs The outputs will be in the same order as defined in the function definition line User de ned function verses script Script Function input function out myfunctionin in input what is your input help lines calculations out in25 outputs printf output 22fn out calculations out in25 Calling the scriptfunction gtgt myScript output 1500 what is your input 5 gtgt a myfunction5 a 15 Variables in the work space in out command window 5 15 I did not make these variables and they are now in i 15 Only the variables that I created are in the command window Why programming is hard and what you can do about it Some challenges with programming 0 You cannot touch code so it is hard to understand or explain to other people 0 There are many ways to get the right answer 0 Some code is depended on other code but some is not 0 Small errors can have a major impact 0 Having a saved variable in the workspace can cause problems 0 It is very hard to guess and check your code 0 Errors in code tend to compound on previous errors 0 You have to think about what you are doing 0 You need to fully understand the problem you are working on Tools to help ow chart Flow charts are visual representations of the ow of processes They are very helpful in allowing you to plan out and test code in a visual manor Symbol What it does circleoval Start stop of the program There should be only one start and only one stop parallelogram Inputoutput rectangle Calculation diamond Decisionloop Must have one arrow in and 2 arrows outtrue condition and false condition NOTE it is very importation that you only have one action going on a time we are not programming for multiple cores so the computer can only do one action at a time Tools to Help pseudo code Pseudo code is code that does not follow the rules of any programming language Pseudo code allows you to get your ideas on paper without having to worry about if you are using the right syntax Think of pseudo code as a very rough draft of your code Pseudo code should be written on paper NOT a computer Tools to help iterative programming Iterative programming is an approach to programming where you write small chucks of code then test the code You repeat this until you are done with the program I am not going to give you an absolute rule on how many lines you can write However you should test your code after you nish any step such as getting all your inputs This means you could write 10 lines before testing your code like when you are declaring your variables or you could go only one line like when you are doing a complex calculation Remember the fewer lines of code you have to search to nd an error the better Tools to help software engineering V I mark p Dmmt yw ggjvm 7 I 1 Software engineering processes are a customized version of the design processes similar to what you learned earlier but with a focused on the challenges of software development I will be using the V model for software development that I modi ed to better represent homework in rst year engineering classes 1 Understanding the assignment 0 READ and do EVERYTHING that the instructions ask you to do 0 You might want to highlight or underline key facts or information 0 Homework in first year engineering classes and many other classes is set up to be done step by step and is graded on if you complete each step and each step is dependent on the previous steps 0 In industry Analysts report that as many as 71 percent of software projects that fail do so because of poor requirements management making it the single biggest reason for project failure bigger than bad technology missed deadlines or change management fiascoes 2 2 Identify the Hidden system Requirements 0 After you figure out what is required of you find the things that you MUST do but MAY NOT be explicitly stated in the instructions This includes comments and headers 0 You need to be aware of Hidden Requirements because that is where you will lose a lot of points even when you think you have done everything right However I do not expect you to write them down 3 Figure out the general steps 0 Come up with a plan of attack to solve the problem 0 Every problem has a specific set of steps that you need to do to get the right answer 0 You do not have to write down the general steps but if you are designing something complicated then you should 0 For program you could make a owchart or any other chart that allows you to plan your code 4 Work out the problem do the coding 0 Since you planed everything out and you know exactly what is expected of you this should be the easy part 2Lindquest C 2005 November 15 Fixing the software requirements mess CO Retrieved from httpwwwciocomarticle14295FixingtheSoftwareRequirementsMess 0 Make sure you test small chunks of code to make sure things are coming out as expected 5 Generate results 0 Come up with a solutions a make sure it is in the correct format 6 Verify completeness 0 Make sure that you have everything that is asked for 0 Also make sure your answers make sense No having things go faster than the speed of light 7 Submitting for grading 0 Submit your homework online or have a hardcopy ready for class 0 If you followed this model you should be getting good grades and you should not be spending too much time on your homework More information on software engineering CS 307 Software Engineering 1 class notes httpwwwcsourdueeduhomesbxd307 System Engineering for Dummies same processes as software engineering but also looks at hardware httpmediawileycomassets5008349781118100738pdf Applied logic if statements If statements are a way for you to have an computer make choices for you General format iflogical expression some code if the logical expression of the if statements is true elseiflogical expression this is optional and you can have as many elseif as you needed some code if the logical expression of the elseif statements is true else this is optional and you need NO logical expression after some code if everything else is false end you must have an end NOTES I For every if you have you need to have an end I elseif and else are optional you do not need to have them I Smart Indent highlight and CtrlI or right Click allows you to see your if statements structure better I You can put as much code as you want inside of an if statement Flowchart Example irt tam quot llc l39lt Gmup I CDH dS lf n ands Ch upz IEJEHd actimn U9 nothing temp EH if tEmp i 60 actian E 39Turn Elseif temp 8U aELiU alga acti n and di factimn THLM 39TMEH CI TI 6 I FIJI I I39M 31 L E 1 r 2 iv 4 Il39 amp v39 139 1 I39 1 39 3 i Applied logic while loops While loops allow user to have the computer do repeated tasks over and over until a logical expression becomes false This is useful because let s say l have an activity that I want to do until some logical conditions become false I could make an quotif statementquot and copy it a million times so I can get the results or I can use a while loop General format declaration of initial values whilelogical expression code you want to run while the logical expression is true code that changes the logical expression end NOTES I For every while you have you need to have an end I You can put as much code as you want inside of a while loops I While loops only run if the logical expression is true I Smart Indent highlight and Ctrli or right click allows you to see your while loop structure better I Ctrlc force stops a while loop that is taking too long to end Flowchart Example Chckti J lnlt1allze Test Variable LoopWHILE the expression is true is logical False expr ssitm J Exit the Loop once the test expression w isjgdlse Continuing Statements quotStatements H While Loop Pitfall In nite Loop In nite loop is a loop that does not stop because you are not updating the logical expression correctly or not at all You can stop an in nite loop manually by pressing ctrc For loops For loops are de nite loops meaning that you know the number of times the loop iterates beforehand For loops do NOT use logic They are controlled by a variable that gets its value from a vector General format fbr loquontrol someVector end this loop will run fer each element in someVector For loops end when you have gone through all the elements of the vector You do not need a logical statement or to change the value of loop control NOTES For every for you have you need to have an end You can put as much code as you want inside of a for loop For loops only run if there are values in someVector The for loop will not run if there are no values in someVector loopControl resets every time the for loop structure is called Smart Indent highlight and CtrlI or right click allows you to see your for loop structure better Flowchart Example ferment owchart structure a r a Etart at the The Increment a mm A eutemetieelly fame Increment to l n End attli39iemll the next la at value value L lp a L155 i V l I definite En l n um e r of 39 cycles Exit the lee afte r a definite numer of repetitions Simple Linear Regression Simple Linear Regression is a way to predict the following model Yaxberror which we simplify to Ypredictedaxb Simple Linear Regression the easy wayquot 0 Can be used for prediction 0 A regression line trendline is created that is a model of the data 0 As long as X is within range of the original data Cannot use line to predict values of data below or above original X values Regression by Eye Just draw a linear regression line trendline on the data This is quick and easy Does not give very good results ie will not produce the same resulted every time or can be inaccurate A line is created that is a model of the data Two point method Find the slope and intercept from the rst and last points on the trendline This is quick and easy Only takes in to account 2 data points so does not give the best prediction and if you chose different data points you can get different results Simple Linear Regression using Least Squares Method This is the preferred method because it takes in to account all data points and will produce the same result every time assuming you are doing it right and using the same data Calculating by Hand Solve for a and b l lll Calculating using MATLAB Remember alphabetical order t before val To nd the coef cients of the linear regression equation y ax b use the poly t command This will give you the coef cients a and b coef cients poly tx y 1 NOTE the 1 is used in this command to tell MATLAB that this is a rst order linear equation To nd the y values of the regression line trendline use the polyval command yPredicted polyvalcoef cients x MATLAB code example X data 1 y data 2 coeff poly t x y 1 y t polyval coeff X sse sumx y tquot2 sst sumy meanyquot2 rsquared 1 ssesst How good is your Simple Linear Regression You can tell how good a regression is by looking at the coef cient of determination It shows the strength of the linear relationship between the independent and dependent variable It shows the extent to which the dependent variable is dependent on the independent variable SSE Sum of Squares of Errors a measure of how well we can predict the dependent variable SST Sum of Squares of Deviations Total a measure of how much variability there is in the original dependent variable a I2 Coef cient of Determination the square of correlation coef cient is a measure of shared variance and is de ned as 1 SSESST r2 varies between 0 and 1 The closer to 1 the better the t r2 1 means y is completely dependent on X Note that a small r2 does not indicate a small error EX For r2 082 means a strong positive relationship between the independent and dependent variable It shows that the value of x predicts 82 of the variability of y 18 is due to other factors Danger of interpolating While it is very tempting to estimate values outside of your given data interpolating this brings extreme risk because you cannot assume that the data follows the same pattern A great example of this is the stock price of Lehman Brothers for the week of August 25 2008 the stock price followed a linear trend of price 712days past August 2512708 with an R squared value of 9721 This is really good regression for the real world however if you attempt to extend the trend for a few more weeks it would fail because Lehman Brothers led for bankruptcy on September 15 2008 making the stock worthless Data from yahoo nance Function discovery Simple linear regression is great for linear data however there is a lot of data that is not linear We can make simple linear regression even more powerful if we can make nonlinear data linear Luckily there is a way to do this Functions we are going to be working with Linear Power Exponential and Logarithmic Look at behavior on axes Look at behavior nearorigin r y 2 k 3quot ff power function linear mootiron I F 2 EM 339 E rm b 3quotva I 2 Look or behavior nearorigiiru Ii Look at behavior hoaraxes exponential funotion 2 ff E w 39 m y EMA f l W gquot Err I39l n we fr logarithmic fijrio39 ori or If E I J a u Linear form The plot that Type of General LInear form With variable shows your equations form substitution data as linear Linear ymx b Linear Linear Standard graph y vs x Exponential yb10mquot ogy mxogb y mXB semilogy ogy vs X Logarithmic xb10my ogx myogb X myB semilogx y vs ogx Power ybxm ogymogxogb y mXB loglog ogy vs ogx Table of functions Transform data into linear form and back Linear l Exponential X l Logarithmic l Power Do nothing To linear form To linear form To linear form you already 1 yb10mX 1 xb10my 1 ybxm have the 2 ogyogb1 2 logx 2 ogyogbxm linearform Omx ogb10my 3 ogyogb 3 ogY 3 logx ogxm og1OmX ogb 4 ogYogb ogb og10my mlogx 4 ogymxlo 4 logx 5 YmXB gb myogb 5 YmXB 5 XmYB Back to general Back to general Back to general form form form 1 YmXB 1 Y mXB 1 XmYB 2 ogyogb 2 ogY 2 logx mlogx mxogb myogb 3 ogyogb 3 1009 3 103909 X ogxm 10mxlogb 10mylogb 4 10Iogy10logb 4 y b10mX 4 x b10my 10quot 9 X m 5 y 10IogblogXquotm 6 y bxm Estimating loglO Use the following properties of logarithms og10ab og10aog10b og10ab og10aog10b You remember the following values 0 og2 og4 og8 and og10 are easy to memorize o og2 03 o og4 06 0 og8 09 og10 1 Examples of this These are all log base 10 examples oglO4 oglO22 oglO2 oglO2 z 6 oglO8 oglO222oglO2 oglO2 oglO2 z 9 oglO5 oglO102og1010 og102 z7 oglO7919z oglO8000z oglO101010222 zlog102 oglO2 oglO2 oglO10 oglO10 oglO10 z 39 MATLAB GUIS Advantages Easy for the user to use no remembering names of variables Looks nice Can use mouse to interact Disadvantages Made up of a lot of functions Easy to mess up and break code for an unknown reason Tradeoff of ease to program to ease of use hard Command line if f 139 39 Less complex programs 39 Scripts quotVFu rJQtLBnsg I More complex programs Easy Difficulty for client to use Easy Difficulty for you to program hard GUIs in MATLAB are made of several functions The actions of GUIs are event driven meaning the user needs to do something before the GUI will do anything useful All you need to do is modify the callback function ComponenttagCa11back of the component you want to cause the program to do something This reference sheet is divided into 2 parts a general approach to programing callback functions and how to do common GUI tasks in MATLAB If you do not understand anything in this reference sheet use your favorite search engine to nd more indepth tutorials and examples like I did to make this sheet Handles where your data is stored In MATLAB GUIs the data of the GUIs is stored in a variable called handles so you can access your data in any part of the GUI Handles has a data type structure I like to think of handles as a wallet with cash variables I make and credit cards GUI components With a wallet the tradeoff for being able to have your money in a single place is to get it You have the inconvenience of opening the wallet For handles to get to your variables you have to type quothandles varibenamequot When using credit cards in addition to having to get the credit card out of your wallet you must use a special machine or your credit card is just a random account number The same is true with GUI components to be able to use GUI components You have to use get or set Once you are done with using the wallet you need to put it in a safe place when you are done For handles you use guidata to put your data in a safe place Programing Callback Functions There are 5 types of actions that you can do in the callback functions to make your GUI work When you design you program you can pick and choose which of the following ve actions you need to use 1 Getting data Before you can make any changes or do any calculations you need to retrieve data from the GUI This is done by the get command When you are working inside the callback function of a GUI component you would type var geth0bject Prqpertythe When you are working in any other function you need to type var gethandlesComponenttag PrqpertyName NOTE PropertyName should be replaced with String when you are reading text or Value when you are getting the state of a component such as a radio button NOTE Use var str2num var to convert var into a number 2 Validate data Check to make sure that the variables you are working with are what you expected You can use an if statement NCTTEquotvisemptystr2numstr returns true if str is just numbers and no letters NCTTEistrcmpstr1str2 returns true if strl and str2 are the same 3 Calculate data Do whatever calculations you need to do or run whatever functions you need to run NOTE Variables that are a part of the handles structure need to be referred to as handlesvar 4 Update the GUI Based on your calculations or data validation you might need to update the GUI To do this you use the set command When you are working inside the callback function of a GUI component you would type set hObject PropertyName PropertyValue When you are working in any other function you need to type set handlesComponenttag PropertyName PropertyValue NOTE PropertyName needs to be a property of the GUI component You can get a list of properties of each GUI component by doubleclicking on a component NOTE Use var num2str var to convert var into a string Return handles bacllt t0 the program Update handles structure Include this as the last line of the function to insure that any changes you make in the functions are able to pass to other functions guidata hObject handles Types of Components Available Note I did not include ActiveX controls because these controls interact with other programs Inputs Outputs Component controls Push Button Slider Static Text Axes Panel visual appeal only Radio Button Check Box Edit Text Popup Menu List box Toggle button Table edit turned onx Button Group Inputs When you are working with inputs you can get three types of inputs strings numbers and Boolean values truefalse input Type of data How to get the users inputted data component inputted Push Button User action Write code in the call back function SHder IVun ber uernput gethandlesslider Value Radio Button Boolean selected get handlesradiobutton Value Check BOX Boolean selected get handlescheckbox Value EdHIT Xt SU ng uernput gethandlesedit String st ng39 twn contents cellstrgethandlespopupmenu String Popup Menu a prede ned usrChoice contentsget handlespopupmenu Value list st ng39 twn contents cellstrgethandles listbox String List box a prede ned usrChoice contentsget handles listbox Value list Toggle button Boolean get handles togglebutton Value Table edit on Matrix get handles uitable Data Button groups In th e uipanel SelectionChangchn Button groups allow you to have multiple buttons linked together so only one appears selected at one time switch get eventdataNewValue Tag radiobuttonl code you want to run when this radio button is selected radiobutton2 code you want to run when this radio button is selected case case you can have as many case statements as you want otherwise Code fbr when there is no match end based off of code from httpbinkdaddercommatabmatIabdu tutoriabuttonsbuttongroupz NOTE you need to set up your table by using the quottable property editorquot by right clicking on your table and selecting Table Property Editor Outputs Outputs Type of info How to output info Static Text Text set handlestext String outputString Note you can use sprintf to get the numbers to look the way you want it works very similar to fprintf Axes Gra phS axes handles axes plot xy or any other plotting command title my GUI plot xlabel independent data with units ylabel depended data with units Adding Pictures If you want to have picture load when the GUI is rst opened put this code in the opening function of your GUI Component Code axis Do NOT picture importdata picfileNamejpg place any code in axes handlesaxes the axis you want to place the picture the create image picture places the picture on axes function set handlesaxes XTick removes the x tick marks set handlesaxes YTick removes the y tick marks UI components picture importdata picfileName jpg eg Push set handles Componenttag CDATA picture Buttons Animating Components Animation is the moving a GUI component a little bit at a time with a small pause between movements MATLAB only supports the running of one loop at a time By having conditional statements in your animation loop that are controlled by UserData property If you want animations to start when the GUI starts running put the animation code in the Outputhn Example code Timer timerTime 60 time is in seconds for TimePasted 11timerTime set handlestext String TimePasted display the time lapsed pause 1 pause for 1 second end Animating while I want to move the object until this is false a Location gethandlesComponenttag Position gets the current component location Location1 Location1 movebeThisManyPixals adjust the x location Location2 Location2 moverbyThisManyPixals adjusts the y location sethandlesComponenttag Position Location changes where you component is pause14 some small time to make you animation look good end lM Hnath g while loop to control the whole animation multiple Conqponent code to animate any object you want to animate all the time 55at This if statement will be true when you want to animate an additional different Component Unnes if gethandlesComponentThatYouwantTOAnimatelater UserData 0 code to animate any object you want to animate at a certain time end pausel chose a time that makes your animations look smooth end Getting Data from other GUls You can get the handles of any GUI by using guidata Once you have them you can do whatever you want to the GUI When you have multiple GUIS open at the same time handlesOfMyGUI guidataMyGUI you now have the handles of a GUI called MyGUI dataFromMYGUI gethandlesOfMyGUIComponenttag data from a component in myGUI PropertyName gets var handlesOfMyGUIvar creates a variable called var with the same value has handlesvar in MyGUI sethandlesOfMyGUIComponenttag in MyGUI PropertyName someval changes data Passing data from one GUI to another using varargin in the GUI of the one that has the data you want to pass myGUIhandlesdataIwanttoPassl handlesdataIwanttoPassZ just like calling a function you can pass as many variables as you want in the gui receiving the data myGUI in this example dataIwanttoPassl varargin1 1 represents the first variable passed dataIwanttoPassZ varargin2 2 represents the second variable passed
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'