Problem with 'disp' function while using 'sym'
3 views (last 30 days)
Show older comments
iamShreyans
on 12 Sep 2019
Commented: iamShreyans
on 13 Sep 2019
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.
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 12 Sep 2019
Edited: KALYAN ACHARJYA
on 12 Sep 2019
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
More Answers (0)
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!