Concept explainers
Answer the question with each of the following code segments. If an error will occur, write ERROR and explain what caused the error.
a. What is stored in Count by the following code?
b. What is displayed on the screen by the following code?
c. What is displayed on the screen by the following code?
d. What is stored in P and C after the following code executes?
a.
What variable is stored in Count.
Answer to Problem 1ICA
The variable stored in Count is 8.
Explanation of Solution
Given data:
Count =0;
for N=10:-0.2:8.5;
Count=Count+1;
end
Program execution:
Steps to execute the MATLAB program:
- 1. Open the command window and paste the given program.
- 2. Press enter.
- 3. Output is displayed in command window.
Enter Count in the command window and execute the program.
>> Count
Count =
8
Conclusion:
Thus, the variable stored in Count is 8.
b.
What is displayed on the screen after executing the given program.
Answer to Problem 1ICA
The output displayed on the screen:
6
12
20
30
42
56
Explanation of Solution
Given data:
for m=3:8
fprintf('%0.0f\n',m^2-m)
end
Program execution:
Steps to execute the MATLAB program:
- 1. Open the command window and paste the given program.
- 2. Press enter.
- 3. Output is displayed in command window.
MATLAB Output after execution of program is displayed as follows.
6
12
20
30
42
56
Conclusion:
Thus, the Output displayed on the screen:
6
12
20
30
42
56
c.
What is displayed on the screen after executing the given program.
Answer to Problem 1ICA
The output displayed in the screen is 56.
Explanation of Solution
Given data:
for m=3:8;
M2=m^2-m;
end
fprintf('%0.0f\n',M2)
Program execution:
Steps to execute the MATLAB program:
- 1. Open the command window and paste the given program.
- 2. Press enter.
- 3. Output is displayed in command window.
MATLAB Output after execution of program is displayed as follows.
56
Conclusion:
Thus, the output displayed in the screen is 56.
d.
What variables are stored in p and C.
Answer to Problem 1ICA
The variables stored in in p and C are p=945 and C=4.
Explanation of Solution
Given data:
S=3;
I=2;
P=1;
C=0;
for K=S:I:S^I
P=P*K;
C=C+1;
end
Program execution:
Steps to execute the MATLAB program:
- 1. Open the command window and paste the given program.
- 2. Press enter.
- 3. Output is displayed in command window.
Enter P and C in the command window and execute the program.
>> P
P =
945
>> C
C =
4
Conclusion:
Thus, the variables stored in in p and C are p=945 and C=4.
Want to see more full solutions like this?
Chapter 20 Solutions
Thinking Like an Engineer: An Active Learning Approach (3rd Edition)
- Please show your solution and at the same time BOX and SPECIFY the answers that corresponds to each blank on the question. Make sure to fill all the blanks. Thank you. STRICKLY FOLLOW THIS: Calculated Answers Express your answers without rounding off and without scientific notation unless instructed otherwise. Multiple Blanks Write powers or subscript as is. Ex: Use b2 if you mean b2 or b2 Spell out Greek letters. Ex: Use pi if you mean greek letter pi Write answers without spaces. Ex: Use 2epsilon0r3 if you mean 3e0r3 Write fractions with a slash. Ex: Use 1/2arrow_forwardWrite a G-Code Program for the part given below. 10 20 40 30 R9 R20 R8 11,98 80 Start Re R7 SSarrow_forwardwrite one command for each case: take data name is 'x' and file name is 'database' Import data form Excel sheet to MATLAB. 1. Export data form MATLAB to Excel sheet. 2. Save data as text file. 3. Load data form text file. 4. Open and close file.arrow_forward
- NUMERICAL METHOD PLEASE FOLLOW THE INSTRUCTIONarrow_forwardQ3: Write two G-code programs using the following figure where units are in inches. a. The first program should use absolute positioning, and b. the second program should use incremental positioning. P4 Finish (6, 4) P2 (1, 3) P3 (4.79, 2) P1 Start (-2, 1) Center (2.5, 1) -2arrow_forward4. Please explain the difference between Modal and Non-modal Codes. Think about which G-code can be omitted in the following NC program and sign such G-code with bracket. 00001 N10 G20 G40 G49 G54 G80 G90 N20 M06 T03 N30 G43 H03 N40 M03 S2000 N50 G00 X0.5 Y0.5 N60 G00 70.2 N70 G01 Z-0.1 F5.0 N80 G01 X0.5 Y1.5 F10 N90 G01 X0.5 Y1.5arrow_forward
- While constructing a building, an engineer need to fix two steel beams together using a bracket as shown in Figure 1. Using absolute coordinate system, construct a G-code program for drilling hole number 2 only. To remove the metal chips the hole should be done in two equal steps. During the drilling, coolant should be on after spindle starts and stop before spindle stops. The spindle speed set to 1750 RPM. Drilling bit in rack number 2 and it should be 2 mm over the work piece. Drilling feed rate is 25 mm/min. Explain each code used in the program in a column. 57.5- 12.5 Hole (4) Hole (3) 30 10 Hole (2) Hole (1) X0 YO ZO 10 15 All dimensions shown are in mm Figure 1arrow_forwardQl: Write true or false a- The body is constant when no force effect of this. b- The moment is force x distance. c- Force is vector quantity. d- The force in the engineering dynamics is zero. e- Space is the geometric region for two coordinates and three coordinates. f- Particle is zero dimensions but have weight. g- Acceleration is a scaler quantity. h- We can use tan law to solve the problems. i- We use the plus in the cosine law when the angle between two force. j- Rivet between two plates is external force.arrow_forwardA person by the name of Huebscher developed a relationship between the equivalent size of round ducts (in air conditioning applications) and rectangular ducts according to (ab) 0.625 (a + b)0.25' D = 1.3- Side of Rectangular Du 400 450 500 550 600 diameter of equivalent circular duct (mm) dimension of one side of the rectangular duct (mm) dimension of the other side rectangular duct (mm) Use VBA to create a custom-made dialog box to return values that shows the relationship between the circular and the rectangular duct dimensions, such as the values of D that would be entered into the table shown below. Length of one side of rectangular duct (length a), mm 125 150 175 122 133 143 122 133 143 122 133 143 122 133 143 122 133 143 where we have the following: D= 100 109 109 109 109 109 a= b= 200 152 152 152 152 152 Calculate Diameterarrow_forward
- Write the G-code with describe each lines : 20.0 40.0 40.0 40.0 60.0 30.0arrow_forwardI am attaching both questions for 4 and 5 with the question in the image. thank you. NOTE : So the last person answered this question WITHOUT refencing the answer for whether question 4 or 5 answeres were given, so i am asking for question 5(or the answer for the question that was NOT solved because it was not referenced.) These were the following answers given to me from the last person on bartleby who answered my question without referencing whether it was the answer for question 4 or 5. 1 pass 2 fail 3 fail 4 passarrow_forwardDavid is working on her farming business and faces the challenge of watering her plants daily,which is a tedious and time-consuming task, especially under the scorching sun. The path shefollows for watering the plants is illustrated in figure 1.David's son has taken on the task of designing a prototype to automate the watering process forher. Figure 2 depicts the design, featuring a set of rods. The curved path represents David'stypical watering route, and the straight rod AB AB is confined to move along the path due to the pinsat its ends. Water sprinklers will be positioned at points A and B to efficiently water the plants.At the instant shown in figure 2, point A has the motion shown while its at the edge of the path.Determine the velocity and acceleration of point B at this instant.arrow_forward
- Elements Of ElectromagneticsMechanical EngineeringISBN:9780190698614Author:Sadiku, Matthew N. O.Publisher:Oxford University PressMechanics of Materials (10th Edition)Mechanical EngineeringISBN:9780134319650Author:Russell C. HibbelerPublisher:PEARSONThermodynamics: An Engineering ApproachMechanical EngineeringISBN:9781259822674Author:Yunus A. Cengel Dr., Michael A. BolesPublisher:McGraw-Hill Education
- Control Systems EngineeringMechanical EngineeringISBN:9781118170519Author:Norman S. NisePublisher:WILEYMechanics of Materials (MindTap Course List)Mechanical EngineeringISBN:9781337093347Author:Barry J. Goodno, James M. GerePublisher:Cengage LearningEngineering Mechanics: StaticsMechanical EngineeringISBN:9781118807330Author:James L. Meriam, L. G. Kraige, J. N. BoltonPublisher:WILEY