Solving two equations two unknowns
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello, I have the following code
% Mohsen Nashel - MAE 316 - Homework 2 - Problem 1
t_sk = 0.0025; %m
dr = 0.00425; %m
sigma_sk = 150; % n/mm^2
sigma_st = 125; % n/mm^2
tau_r = 120; % n/mm^2
syms t_st b
E = [((tau_r*pi*dr^2)./2*b)== ((2*sigma_st*t_st*(b-dr))./b), ((2*sigma_st*t_st*(b-dr))./b) == ((sigma_sk*t_sk*(b-dr))./b)];
S = solve(E,t_st,b)
I am trying to solve for t_st and b but its only giving me the return
S =
struct with fields:
t_st: [2×1 sym]
b: [2×1 sym]
I need to find the actual values because they don't show
댓글 수: 3
Walter Roberson
2020년 2월 21일
It gives me some weird answers
It gives you exact solutions, because the purpose of solve() is to give exact solutions whenever possible. If you do not want exact solutions then you should consider using vpasolve() instead of solve()
The meaning of "exact" for this purpose is a bit convoluted. The short short summary is:
If you are using solve() with any floating point constants in your formula, you are probably making a mistake.
If you are using vpasolve() with any floating point constants in your formula, you are probably still making a mistake, but at least you will have signaled that you only want approximate solutions and are willing to live with the fact that the answer might be wildly wrong on a relative scale.
답변 (1개)
Priyanshu Mishra
2020년 2월 25일
Hi Jacob,
You have written in the last line "its only giving me the return " (which is an structure). For systems of equations, solve returns a structure. To access the value of t_st and b you can use the following command
S.t_st
S.b
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!