matlab - Write a program which takes a character string input and returns penultimate character. Whats wrong with my code? -
Using eBooks to learn new and new in Matlab.
The question was:
Write a MATLAB program that takes its input as a string of characters and prints its last letter.
The code I created:
A = four ('X'); X = input ('enter a string of characters:', 's'); disp (x (size -1)); What am I doing?
When I run it, the input is part and I get an error, I think this is due to the wrong index reference?
Thanks
is a function, not a variable, therefore, arguments for it , Such as size (x) which will return [1 5] for 1x5 matrix. Try X (length (x) -1) or more precisely, X (end-1) and Info:
- The dimension of return matrix.
-
Size (matrix, dimension) Returns the number of elements in the dimension (row, column, etc.) of a matrix. - Returns the number of elements of a matrix for 2D matrix, this is
#rows * #cols . For any matrix, this is equivalent to prod (matrix) . - Finds the number of elements with the largest dimension of the matrix. This is
maximum (size is equal to matrix)
Comments
Post a Comment