You can use a for loop in MATLAB to create an array containing numbers decreasing from 11 to 1. Here is an example code:
main.m156 chars8 lines
This code initializes an empty array called numbers
and then uses a for loop to iterate from 11 to 1 with a step of -1. Inside the loop, each number is appended to the array using the square bracket concatenation [numbers i]
. Finally, the resulting array is displayed using the disp
function.
This will output the array [11 10 9 8 7 6 5 4 3 2 1]
, which contains the numbers decreasing from 11 to 1.
gistlibby LogSnag