Your loop wasn’t iterating because inMATLAB,for loops by default count upward, so if the terminal value is less than the initial value, the loop is satisfied and never iterates. You need to decrement it by telling it to count down, specifying the interval to (in this instance) to be-1;
Your‘temp’ variable subscript needs to ‘look back’ (which is to say to add1 to‘i’) at every iteration, and add1 to the previous value of‘str’;
Yourstrcat arguments were reversed.
A minor observation: it’s best to not use‘i’ or‘j’ as loop counters. They are the imaginary operators inMATLAB.
Best Answer