Problem with 'disp' function while using 'sym'

8 ビュー (過去 30 日間)
iamShreyans
iamShreyans 2019 年 9 月 12 日
コメント済み: iamShreyans 2019 年 9 月 13 日
I wanted to view my answer in square root form instead of decimals so I am using the 'sym' function. But while using 'disp' to show my answers, I'm getting the following error:
Error in sym/disp (line 9)
numbers = regexp(X(1).s, '^_symans_\[\[(\d+)', 'tokens');
while running this code:
clc
clear
th = 60;
c = sym(cosd(th));
s = sym(sind(th));
D = sym([7 5 7]');
T = sym(eye(4));
R = sym([1 0 0; %line number 9
0 c -s;
0 s c]);
T(1:3,1:3) = R;
T(1:3,4) = D;
disp('1T2:');
disp((T));
P = [2 4 6 1]';
disp('P:',T*P);
I believe there's some problem with the last line of my code where I've used 'P:' in the disp function because when I run just 'disp(T*P)', I'm not facing any issues.

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 12 日
編集済み: KALYAN ACHARJYA 2019 年 9 月 12 日
You are trying to diplay displaying a description and variable value in the same line using disp, please look at fprintf function. Also see the detail of @Stephen Cobeldick Answer's regarding similar question here
Or easy way in your case:
disp('P:');
disp(T*P);
Result:
P:
9
7 - 3*3^(1/2)
2*3^(1/2) + 10
1
  1 件のコメント
iamShreyans
iamShreyans 2019 年 9 月 13 日
Thanks a lot for the help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by