Problem with 'disp' function while using 'sym'

조회 수: 12 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion 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