Using symbolic variables in matrix-multiplication with elements consisting of trig-functions I came across a symbol that I have not seen before. It shows up in two elements in the result:
38769523591\\\r\n65965*Dq3*sin(2*q2 + q3)
and
-\\\r\n 1578177954729427/1073741824
What is this mysterious operator ? I tried using vpa(), but still the operator got promped. However, using
vpa(ans,2)
the operator disappeared. I guess it has something to do with numerical accuracy in the symbolic math engine...

6 件のコメント

KSSV
KSSV 2017 年 4 月 25 日
Copy the full code.
Stephen23
Stephen23 2017 年 4 月 25 日
Have a look at the "Special Characters" listed here:
Steven Lord
Steven Lord 2017 年 4 月 25 日
I agree with KSSV. Please post a small sample of code with which you can reproduce this behavior so that we can try to reproduce the behavior as well.
Ronny Landsverk
Ronny Landsverk 2017 年 4 月 25 日
I have no problem with posting code, but in this case there are many calculations performed prior to this behaviour... Hence, the symbolic expressions are quite long! I can attach the functions used in the calculations and show how to re-create the behaviour.
q = sym('q',[3,1]);
Dq = sym('Dq',[3,1]);
DDq = sym('DDq',[3,1]);
M = inertiaMatrix(q);
C = corCenMatrix(q,Dq);
G = springMatrix(q);
T = M*DDq + C*Dq + G
Jan
Jan 2017 年 4 月 25 日
Does it shed any light to your problem that \r\n is the standard DOS line break?
Ronny Landsverk
Ronny Landsverk 2017 年 4 月 25 日
Hi Jan Simon. Yes it does. However, I think this is a bug since these show up as part of an answer prompted by MATLAB... Do you have a comment ?

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

 採用された回答

Jan
Jan 2017 年 4 月 25 日

3 投票

In format specificators e.g. in sprintf the backslash is used as escape character: the following character get a special meaning: \r is a "carriage return" and \n a "new line". Both together are used by DOS applications as line break. To get a backslash charater, \\ is used.
Remark: You can ask an internet search engine for "\r \n" also. I like this forum very much, but e.g. Google finds an answer in less than a second.

3 件のコメント

Ronny Landsverk
Ronny Landsverk 2017 年 4 月 25 日
Hi Jan Simon... new line - got it. However, I think this is a bug since these show up as part of an answer prompted by MATLAB... Do you have a comment ?
ali
ali 2017 年 12 月 17 日
I have a same problem, how to use new line???
Walter Roberson
Walter Roberson 2017 年 12 月 17 日
strrep(TheOutput, '\\\r\n', '')
Note that in cases where you get these characters, it would not be uncommon to see a message about truncated output. To view the whole output, see the work-around I gave in the link in my answer.

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

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 4 月 26 日

3 投票

It is a bug in the output of long symbolic expressions. I submitted a report about it a few months ago. It would not hurt to submit a report yourself, so that they know I am not the only person affected.
Mohamed Abdelhamid
Mohamed Abdelhamid 2017 年 5 月 7 日

1 投票

I did encounter that "\\\r\n" in some really long symbolic expressions. All I did was use find/replace to replace it with nothing. It did work pretty nice after that and the calculations were indeed correct.

タグ

質問済み:

2017 年 4 月 25 日

コメント済み:

2017 年 12 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by