フィルターのクリア

Having issues with understanding the formatting of an error message.

1 回表示 (過去 30 日間)
Justin Schrout
Justin Schrout 2015 年 6 月 9 日
回答済み: Nobel Mondal 2015 年 6 月 9 日
I have code that is written, but there is one line that is absolutely throwing me off. I have,
error(['Variable ',39,'altitudeMode',39, ' should be one of ' ,39,'clampToGround',39,', ',10,39,'relativeToGround',39,', or ',39,'absolute',39,'.' ])
and when executed, it reads,
Variable 'altitudeMode' should be one of 'clampToGround', 'relativeToGround', or 'absolute'.
My question is why, What are the numbers 39 and 10, and why is the entire message inside brackets []?

回答 (1 件)

Nobel Mondal
Nobel Mondal 2015 年 6 月 9 日
Hey Justin,
[] is used for horizontal concatenation of arrays. Texts inside ' ' are treated as character arrays and the numbers represent ASCII values for a character.
>> % Example
>> string1 = 'Justin'; string2 = 'Schrout';
>> newString = [string1, 32, string2]
newString =
Justin Schrout
In your code, 39 is the ASCII value for the character ' and 10 for new line. Try once without them and you would know.
Thanks,
Nobel.

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by