Solving two equations two unknowns

3 views (last 30 days)
Mohsen Nashel
Mohsen Nashel on 21 Feb 2020
Answered: Priyanshu Mishra on 25 Feb 2020
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 Comments
Mohsen Nashel
Mohsen Nashel on 21 Feb 2020
It gives me some weird answers. Is my code right to begin with? I am trying to put this relationship
Walter Roberson
Walter Roberson on 21 Feb 2020
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.

Sign in to comment.

Answers (1)

Priyanshu Mishra
Priyanshu Mishra on 25 Feb 2020
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.

Community Treasure Hunt

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

Start Hunting!