create a loop that print variable "c" n times in matlab

To create a loop in MATLAB that prints the variable c n times, you can use a for loop with the function fprintf to print the variable:

main.m
for i = 1:n
    fprintf('%d ', c)
end
38 chars
4 lines

In this code, i is the loop counter and it starts at 1 and goes up to n. On each iteration of the loop, the code uses fprintf to print the value of c followed by a space. The %d specifies that the value of c is an integer.

You can replace %d with any other format specifier to print the value of c in a different format (e.g. %f for a floating-point value).

related categories

gistlibby LogSnag