contains numbers decreasing from 11 to 1 in matlab

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.m
numbers = []; % create an empty array

for i = 11:-1:1
    numbers = [numbers i]; % append each number to the array
end

disp(numbers); % display the array
156 chars
8 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.

related categories

gistlibby LogSnag