not able to evaluate the value for an equation using the data from a table, table is three columns data

조회 수: 2 (최근 30일)
%creat symbol for axial force, length, thickness, displacemnent and width
syms f l t d w
%define governing equations for parameter
stress = f./(t*w)
strain = d./l
%measurement resolution and uncertainty
%zeroth order uncertainty
%define symbolic data
T = readtable('Intro_specimen 2.txt');
f = T(:,2);
l = 6.125;
t = 0.057;
d = T(:,1);
w = 0.414;
%substitute value into equation
stress = eval(stress);
strain = eval(strain);
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 9월 10일
stress = eval(stress);
Never eval() a symbolic object. eval() of a symbolic object is not formally defined, but in practice it is equivalent to eval(char(TheSymbolicObject)) . That is a problem because the character representation of symbolic objects is in a computer language that is not MATLAB and is not the internal MuPAD programming language.
syms x real
y = piecewise(3 < x & x < 5, 2, 4)
y = 
char(y)
ans = 'piecewise(x in Dom::Interval(3, 5), 2, symtrue, 4)'
x = pi
x = 3.1416
eval(y)
Error using sym/eval
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
... which is happening because "x in Dom::Interval" is not valid MATLAB syntax.
Pulkit
Pulkit 2022년 9월 13일
Try using 'readmatrix' function instead of 'readtable' as readtable outputs table object which is not supported by element wise operations. If problem still presist please share the exact error message you are getting and also type of data in Intro_specimen 2.txt

댓글을 달려면 로그인하십시오.

채택된 답변

Seth Furman
Seth Furman 2022년 9월 13일
편집: Seth Furman 2022년 9월 13일
You just need to change the parentheses-() to curly braces-{} when pulling data of the table.
T = array2table(magic(3))
T = 3×3 table
Var1 Var2 Var3 ____ ____ ____ 8 1 6 3 5 7 4 9 2
%creat symbol for axial force, length, thickness, displacemnent and width
syms f l t d w
%define governing equations for parameter
stress = f./(t*w)
stress = 
strain = d./l
strain = 
%measurement resolution and uncertainty
%zeroth order uncertainty
%define symbolic data
f = T{:,2}; % <-- curly braces instead of parentheses
l = 6.125;
t = 0.057;
d = T{:,1}; % <-- curly braces instead of parentheses
w = 0.414;
%substitute value into equation
stress = eval(stress)
stress = 3×1
42.3765 211.8824 381.3883
strain = eval(strain)
strain = 3×1
1.3061 0.4898 0.6531

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by