Symbolic equation simplification output, such as x/y from two equations

8 vues (au cours des 30 derniers jours)
Gerard Nagle
Gerard Nagle le 18 Oct 2022
Commenté : John D'Errico le 22 Oct 2022
I was working with matlab symbolics, and was doing this pipe flow example from a text book (Chin Fluid Mechanics, Q4.13 pg 329)
I got it out by hand, but decided to do it in MATLAB.
The code below works fine, but I have a question on how to get the output in a more concise command for the U_o/u_max ratio directly rather than have to know that it is divided by u_max
syms u(r) r u_max R U_o
u(r) = u_max*(1-r/R)^(1/7)
u(r) = 
Q(r) = 2*pi*u(r)*r
Q(r) = 
Q_out = int(Q(r),r,0,R)
Q_out = 
Q_in = pi*R^2*U_o
Q_in = 
(isolate(Q_in==Q_out,U_o)/u_max)
ans = 
Is there a way to get MATLAB to give the output in terms of U_o/u_max directly from some function such as from the Formula Manipulation and Simplification from the Formula Rearrangement and Rewriting on MATLAB help Formula Manipulation and Simplification - MATLAB & Simulink - MathWorks United Kingdom
Looking under Rewriting & Decomposition, I don't see a function that does this directly.

Réponses (1)

John D'Errico
John D'Errico le 18 Oct 2022
Modifié(e) : John D'Errico le 18 Oct 2022
If you don't know what umax is, where would it go? What do you hope to see here as a result? You are computing the ratio, u0/umax. Correct? Is that not what you got?
You can always call it something else. Feel free to pick a name, anything you want. Maybe uratio. So at the end, you might do this...
syms U_ratio
subs((isolate(Q_in==Q_out,U_o)/u_max),U_o/U_max,U_ratio)
But what function would you expect would do that for in some automatic way, thus know what you want to see, and produce the result it thinks would make you happy? If it could do that much, you would tell it to read the book, and do the exercises and examples for you. Of course then, you would not need to tell it to read the book, since it could write the book itself. You may see where this is all going to end badly for us. That would be a computer I'd be very worried to see. ;-)
  2 commentaires
Gerard Nagle
Gerard Nagle le 18 Oct 2022
Hi John, thanks for your answer and looking at my question.
Maybe I ill posed the question, but what I was trying to ask, is the following.
I know what answer I expect from the question, I was asking if there is a command or construct in MATLAB that the ratio required, in this case u0/umax can be put in as an argument that outputs the result directly.
The solve command solve(Q_in==Q_out,U_o) will give out 49umax/60, but solve doesnt recognise solve(Q_in==Q_out,U_o/u_max) which gives an answer
ans = struct with fields:
U_o: 0
u_max: 0
John D'Errico
John D'Errico le 22 Oct 2022
As I said, you can simply substitute for U_o/U_max at the end. Or you could do it at some earlier point, thus representing the problem in terms of a different variable, perhaps called U_ratio = U_0/U_max. Then you would just solve for U_ratio.

Connectez-vous pour commenter.

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by