Change a symbol to a number

27 次查看(过去 30 天)
Andrew Tormanen
Andrew Tormanen 2020-2-13
I am doing a system of equations, and I want to solve the equations part of the way with a variable in the place of a number for simplicity's sake and then substitute a number for that variable. It never works. I've tried subs, solve, and just about every other program that I can find, and every single one leave the variable in the equation and ignore the other code that i write. Please help.
syms k1 r theta yield v
%Mode 1 Base Equations
sigxx = k1/sqrt(2*pi*r)*cos(theta/2)*(1-sin(theta/2))*sin(3*theta/2);
sigyy = k1/sqrt(2*pi*r)*cos(theta/2)*(1+sin(theta/2))*sin(3*theta/2);
sigxy = k1/sqrt(2*pi*r)*sin(theta/2)*(cos(theta/2))*cos(3*theta/2);
sigzz = v*(sigxx+sigyy);
%Mode 1 Stresses
sig1 = (sigxx+sigyy)/2+sqrt(((sigxx-sigyy)/2)^2+sigxy^2);
sig2 = (sigxx+sigyy)/2-sqrt(((sigxx-sigyy)/2)^2+sigxy^2);
sig3 = sigzz;
v = 0.3 %plane strain
%Von Mises Effective Stress. Solve for r.
sige = sqrt((sig1-sig3)^2+(sig2-sig3)^2+(sig2-sig1)^2)/sqrt(2)==yield;
[ry] = solve(sige,r)
  1 个评论
Walter Roberson
Walter Roberson 2020-2-13
subs(ry, yield, 5.749)
For example.
This will not change ry unless you assign the result to ry.

请先登录,再进行评论。

回答(1 个)

Swetha Polemoni
Swetha Polemoni 2020-9-3
Hi,
In order to assign number/value to symbols subs()" can be used. The following code snippet is for better understanding of assigning values to multiple symbols
s1=subs(sige, [k1, theta, v, yield], [value1, value2, value3, value4]);

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by