Category Archive for: Programming with MATLAB

A College Enrollmet ModeI : Part 1

A College Enrollmet ModeI : Part 1 As an example of how simulation can be used for operations research, consider the following college enrollment model. A certain college wants to analyze the effect of admissions and freshman retention rate on the college’s enrollment so that it can predict the future need for instructors and other…

Read More →

Using the-switch Structure for Calendar Calculauons

Using the-switch Structure for Calendar Calculauons Use the swi tch structure to compute the total elapsed days III .1year, given the number (1-12) of the month, the day, and an indication of whether or nut the year l~ d kJr vear • Solution Note that February has an extra day if the year is a leap…

Read More →

Time to Reach a Specified Height

Time to Reach a Specified Height Consider the variable-mass rocket treated in Example 4.5-2. Write a program to determine how long it takes for the rocket to reach 40,000 ft if the bum time is 50 see . • Solution The pseudocode appears in Table 4.5-3. Because we do not know the time required, a while…

Read More →

Height and Speed of a Projectile

Height andSpeed of a Projectile The height and speed of a projectile (such as a thrown ball) launched with a speed of Vo at an angle A to the horizontal are given by’ where g is the acceleration due to gravity. The projectile will strike the ground when h(l) = 0, which gives the time to…

Read More →

Data Storing

Data Storing A vector x’ bas been obtained from measurements. Suppose we want to consider any data value in the -range -0.1 < x < 0.1 as being erroneous. We want to remove all such elements 3IW replace them ‘with zeros at the end of the array. Develop two ways of doing .this. An eumple is given…

Read More →

Flight of an Instrumented Rocket

Flight of an Instrumented Rocket All rockets lose weight as they bum fuel; thus the mass of the system is variable. The following equations describe the speed v and height h of a rocket launched vertically, neglecting air resistance. They can be derived from Newton’s law where mo is the rocket’s initial mass, q is the rate…

Read More →

Summary

Summary Now that you have finished this chapter, you should be able to write programs that can perform decision-making procedures; that is, the program’s operations depend on results of the program’s calculations or on input from the user. Sections 4.2, 4.3, and 4.4 covered the necessary functions: the relational operators, the logical operators and functions, and the conditional…

Read More →

The switch Structure

The switch Structure The switch structure provides an alternative to using the if, elseif, and else commands. Anything programmed using switch can also be programmed using it structures. However, for some applications the switch structure is more readable than code using the~if structure. The syntax is . switch input expression (scalar-or string) case value 1 statement group…

Read More →

Debugging MATLAB Programs

Debugging MATLAB Programs Use of the MATLAB Editor/Debugger as an M-file editor was discussed in Section 1.4 of Chapter 1. Figure 1.4-1 (in Chapter 1) shows the Editor/Debugger screen. Figure 4.7-1 shows the Debugger containing two programs to be analyzed. Here we discuss its use as a debugger. The Editor/Debugger menu bar contains the following items: File, Edit, Text,…

Read More →

Conditional Statements

Conditional Statements In everyday language we describe our decision making by using conditional phrases such as.If I get a raise, I will buy a new car. If the statement, I get a raise, is true, the action indicated (buy a new car) will be executed. Here is another example: If I get at least a $100 per week…

Read More →

Back to Top