Why do I get the error 'Missing operator, comma, semicolon, or white space.' when I do not have a space between elements of my matrix?

12 vues (au cours des 30 derniers jours)
Why do I get the error 'Missing operator, comma, semicolon, or white space.' when I do not have a space between elements of my matrix?
I have the following code:
a = 2;
b = 'string';
temp = [b '-' num2str(a) ':'num2str(a)]
If I run the code on MATLAB 6.5 (R13), I get the following error:
??? temp = [b '-' num2str(a) ':'num2str(a)]
|
Error: Missing operator, comma, semicolon, or white space.
This code runs without error in MATLAB 5.2 (R10) and MATLAB 5.3 (R11).

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 27 Juin 2009
MATLAB 6.5 (R13) requires that whitespace, a comma, or a semicolon separate the elements of a matrix. This is a change from previous versions of MATLAB. Running the same code in MATLAB 6.0 (R12) will give the following warning:
Warning: Future versions of MATLAB will require that whitespace, a comma,
or a semicolon separate elements of a matrix. Please type
"help matrix_element_separators" at the MATLAB prompt for more information.
Please add a space between elements in your matrix. For example:
a = 2;
b = 'string';
temp = [b '-' num2str(a) ':' num2str(a)]

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by