A thermal test records the following temperatures in degrees Celsius at times 0 through 9 s, one reading per second. The MATLAB code analyzes only these recorded samples; no interpolation between readings is assumed.
T = [74 76 71 75 77 79 78 70 72 74]; hot = T > 72; previous = [false hot(1:end-1)]; beforePrevious = [false false hot(1:end-2)]; starts = hot & ~previous; triples = hot & previous & beforePrevious; nStarts = sum(starts); nTriples = sum(triples);
An episode starts when a hot reading follows a non-hot reading. The inserted false values mean the first recorded reading starts an episode if it is hot. A three-sample window qualifies when all three consecutive recorded readings are hot, and overlapping windows count separately.
Determine nStarts, the number of episode starts, and nTriples, the number of qualifying three-sample windows. Enter both counts as exact integers.
Unlock full course notes by signing up
Average the accepted powers
A resistor has resistance R=2.00 ΩR=2.00\ \OmegaR=2.00 Ω. Five equally weighted current readings are stored as I = [1 2 3 4 5] in amperes. Calculate the arithmetic mean of the individual powers Pi=Ii2RP_i=I_i^2RPi=Ii2R using only readings from 2 A through 4 A, inclusive. Report your answer in watts, to one decimal place.
Trace vectorized voltage saturation
An actuator accepts command voltages from 0 V through 8 V. The following MATLAB code limits requested voltages while retaining their original positions:
Complete the table with the corresponding entries of low, high, and the final vector y. Enter logical values as exact integers 0 or 1 and voltages as exact integers in volts.
Repair a sample alignment error
In modern MATLAB with implicit expansion, three travel distances are stored as the row vector d = [6 12 20] in metres. Their corresponding travel times are stored as the column vector t = [2; 3; 4] in seconds. A student evaluates v = d ./ t to calculate one average speed per trip.
Which diagnosis and correction preserve the intended pairing?
Filter before dividing
A contact-pressure calculation uses paired force readings F = [0 12 18 20] in newtons and contact areas A = [0 3 0 5] in square metres. Zero areas are invalid readings. For positive areas, pressure is pi=Fi/Aip_i=F_i/A_ipi=Fi/Ai.
The output must retain all four sample positions, contain zero at invalid positions, and avoid evaluating any division by zero. Given good = A > 0;, which code meets all three requirements?