Change a symbol to a number

조회 수: 22 (최근 30일)
Andrew Tormanen
Andrew Tormanen 2020년 2월 13일
답변: Swetha Polemoni 2020년 9월 3일
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