There is a difference between string and char array since R2016b. Before that they could be used interchangeably, but now that is no longer true (although I believe some doc pages are still not careful about this).
The title and description have been updated, along with a few new test cases.
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
Determine whether a vector is monotonically increasing
12211 Solvers
The Goldbach Conjecture, Part 2
1301 Solvers
How to find the position of an element in a vector without using the find function
2482 Solvers
Create a cell array out of a struct
529 Solvers
498 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!