Change a symbol to a number

23 ビュー (過去 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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by