write code that adds a 1 to the end of each name in your name vector in matlab

Assuming you have a name vector in MATLAB named names, you can add a '1' to the end of each name using the following code:

main.m
for i = 1:length(names)
    names{i} = strcat(names{i}, '1');
end
66 chars
4 lines

This code loops through each name in the names vector and adds a '1' to the end of the name using the strcat function, which concatenates two strings. The resulting modified name is then stored back into the same names vector in the ith index.

related categories

gistlibby LogSnag