Evaluate values of a vector with values of variable p

1 次查看(过去 30 天)
Hi guys!
I am having a bit of a problem with a code. In this case I have calculated values of exx and eyy, which depend on p. After having computed this two vectors, I want to obtain the values of vector uc which depends on the values of exx and eyy related with the particular value of p.
However, when I try to substitute all the exx and eyy values into uc, I do not obtain the correct substitution as I am only obtaining the same result, which also keeps depending on p (I do not know why if I am giving p values to the two previous vectors). I do not know if I have to do it with another FOR value, which allows me to store a certain value of p and pair it to the values of exx and eyy.
Thanks a lot!
syms E ex ey r v t p
Pa=(E*ex)/((r/2*t)-v*r/t);
Po=(E*ey)/(-v*(r/2*t)+r/t);
%Value of all derivatives
%Calculation of the derivatives
dPa1=diff(Pa,E);
dPa2=diff(Pa,ex);
dPa3=diff(Pa,r);
dPa4=diff(Pa,v);
dPa5=diff(Pa,t);
dPo1=diff(Po,E);
dPo2=diff(Po,ey);
dPo3=diff(Po,r);
dPo4=diff(Po,v);
dPo5=diff(Po,t);
%Values of u
u1=sqrt((0.05*70*10^3)^2/3); % u for E coefficient
u2=sqrt((0.05*0.3)^2/3); % u for v Poisson's coefficient
u3=sqrt(1^2/3); % u for r
u4=sqrt(0.01^2/3); % u for t
u5=sqrt((5*10^-6)^2/3); % u for strain
%Now we give values to all the variables
E=70*10^3;
v=0.3;
r=33;
t=0.1;
exx=[];
eyy=[];
ex=(((p*r)/(2*t))-v*((p*r)/t))*1/E;
ey=(-v*((p*r)/(2*t))+((p*r)/t))*1/E;
uc=[];
ucc=[];
for p=0:0.001:0.2
exx=[exx eval(ex)];
eyy=[eyy eval(ey)];
uc=[uc sqrt((eval(dPa1)*u1)^2+(eval(dPa2)*u2)^2+(eval(dPa3)*u3)^2+(eval(dPa4)*u4)^2+(eval(dPa5)*u5)^2+(eval(dPo1)*u1)^2+(eval(dPo2)*u2)^2+(eval(dPo3)*u3)^2+(eval(dPo4)*u4)^2+(eval(dPo5)*u5)^2)]; %uc in terms of p
end

采纳的回答

Walter Roberson
Walter Roberson 2022-10-23
eval() of a symbolic expression is not defined. Use subs() and double()
  2 个评论
Walter Roberson
Walter Roberson 2022-10-23
eval() of a symbolic expression is in practice eval of char() of the expression. See https://www.mathworks.com/matlabcentral/answers/1833228-import-a-symbolic-expression-to-simulink-and-plot-it#answer_1081478 for why that does not work.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by