I need help with shifting the values
Ältere Kommentare anzeigen
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 = ShiftValues(1:3)
end
Akzeptierte Antwort
Weitere Antworten (1)
Joshua Olatunji
am 23 Feb. 2021
3 Stimmen
A more general way for any array is:
% Write a statement to shift the array contents 1 position to the left
sampleReadings = sampleReadings([2:end]);
% Assign the rightmost element with -1
sampleReadings = [sampleReadings(1:end),-1]
1 Kommentar
saphir alexandre
am 30 Jan. 2022
thank you so much i was really struggling to understand this question
Kategorien
Mehr zu Polar Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!