Why this solution isn't correct? I tried this code on Matlab for pc and it's run correctly, but here on Matlab Cody's platform, it doesn't run. Someone can help me? Thanks
Look at the errors—your function never defines the output variable y.
Thank you for the help
y = [x(1),x(end)];
#strcat(x(1),x(length(x)));
very easy like it!
Well, I guess my understanding that string is defined using (" " , i.e. double quotations) is incorrect. I thought class string was formally distinguished from char (defined using ' ', i.e. single quotes). I should have looked at the test-suite.
Yes, the title should be "Return the first and last character of a char array"
Nice!
Only need:
out = x([1 end])
This is legal even if length(x) == 1, because in that case, x(1) == x(end)
that is it
405 Solvers
525 Solvers
2099 Solvers
Matlab Basics - Absolute Value
360 Solvers
569 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!