Using cos function in matrix leads to invalid input character

4 ビュー (過去 30 日間)
Antoine Compagnie
Antoine Compagnie 2016 年 6 月 20 日
編集済み: James Tursa 2016 年 6 月 22 日
I have an unexpecetd error when trying to
>> Rz= [cos(0.2) -sin(0.2) 0; sin(0.2) cos(0.2) 0; 0 0 1]
Rz= [cos(0.2) -sin(0.2) 0; sin(0.2) cos(0.2) 0; 0 0 1]
Error: The input character is not valid in MATLAB statements or
expressions.

回答 (1 件)

James Tursa
James Tursa 2016 年 6 月 20 日
編集済み: James Tursa 2016 年 6 月 20 日
You have special unprintable characters between the "cos" and the "(" characters, and between the "sin" and the "(". You need to delete these. E.g., just copy and paste what you have written above into the MATLAB command line and you will see them as red squares. I am guessing you didn't type this in by hand originally, but copied it from a document or web page and didn't realize those special characters were there.
  2 件のコメント
Antoine Compagnie
Antoine Compagnie 2016 年 6 月 22 日
Thank you for considering my question! However, I copied and past what I have written above into the MatLab command line and I didn't had red squares... Actually I even remindhaving written the whole matrix myself!
James Tursa
James Tursa 2016 年 6 月 22 日
編集済み: James Tursa 2016 年 6 月 22 日
The characters are definitely there. Try typing it in again from scratch. Or just copy and paste this which has those special characters removed:
Rz= [cos(0.2) -sin(0.2) 0; sin(0.2) cos(0.2) 0; 0 0 1]

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by