I need help with shifting the values
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Joshua Olatunji
el 23 de Feb. de 2021
3 votos
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 comentario
saphir alexandre
el 30 de En. de 2022
thank you so much i was really struggling to understand this question
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!