Change a symbol to a number

7 visualizaciones (últimos 30 días)
Andrew Tormanen
Andrew Tormanen el 13 de Feb. de 2020
Respondida: Swetha Polemoni el 3 de Sept. de 2020
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 comentario
Walter Roberson
Walter Roberson el 13 de Feb. de 2020
subs(ry, yield, 5.749)
For example.
This will not change ry unless you assign the result to ry.

Iniciar sesión para comentar.

Respuestas (1)

Swetha Polemoni
Swetha Polemoni el 3 de Sept. de 2020
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]);

Community Treasure Hunt

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

Start Hunting!

Translated by