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 个评论
Mohsen Nashel
Mohsen Nashel 2020-2-21
It gives me some weird answers. Is my code right to begin with? I am trying to put this relationship
Walter Roberson
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
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
For information on the solve function, you may refer to this link.

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by