Assign multiple values to array

2 次查看(过去 30 天)
I want to assign different values to different parts of my array like below. 1 to 10 gets assigned 99, end-1 to end gets 98. How can i do it ?
test([1:10 end-1:end]) = [99 98];
test([1:10 end-1:end]) works. I am able to print the output

采纳的回答

KSSV
KSSV 2016-6-24
test(1:10) = 99 ;
test(end-1:end)=98 ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by