Write three statements to shift the SampleReadings\' contents 1 position to the
ID: 3859882 • Letter: W
Question
Write three statements to shift the SampleReadings' contents 1 position to the left. The rightmost element after shifting should be assigned -1. Ex: If SampleReadings is [12, 85, 43], then after shifting SampleReadings becomes [85, 43, -1]. Your Function function SampleReadings = ShiftValues(sampleReadings) % SampleReadings: Array containing 3 elements % Write three statements to shift the SampleReadings array contents 1 position to the left % Note: The rightmost element should be -1 SampleReadings = SampleReadings: end Code to call your funcion ShiftValues ([12, 85, 43])Explanation / Answer
The code is provided below,
function sampleReadings = ShiftValues(sampleReadings)
% sampleReadings: Array containing three elements
sampleReadings[0]=sampleReadings[1]
sampleReadings[1]=sampleReadings[2]
sampleReadings[2]=-1
sampleReadings=sampleReadings
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.