A health app records a user\'s weight and displays the change in weight from the
ID: 3863388 • Letter: A
Question
A health app records a user's weight and displays the change in weight from the previous measurement to the next (i.e. Array(2)-Array(1), Array(3) - Array(2), ...) Assign weightChange win the difference between elements in weightRecord. Ex If weightRecord is [120, 125, 130, 127], then weightChange is [5, 5, -3] function weightChange = CalculateDifference(weightRecord) % weightRecord: Array of weights in pounds % Assign weightChange with the difference between elements in weightRecord weightChange = weightRecord; endExplanation / Answer
function weightChange = CalculateDifference(weightRecord)
for a = 2:length(weightRecord-1)
weightChange(a-1) = weightRecord(a)-weightRecord(a-1);
end
end
weightRecord = [93 87 72 66 95 49 33 21 17];
CalculateDifference(weightRecord)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.