How Can MATLAB Automatically Solve and Apply Values in Equations?

AI Thread Summary
The discussion focuses on solving the equation P*v = 1*8.314*T for T using MATLAB. The user seeks a method to automate the calculation of temperature values by plugging in different values of P and v. They express difficulty in using symbolic functions within an anonymous function context in MATLAB. A suggestion is made to manually rearrange the equation to isolate T, which could simplify the process. The conversation highlights the challenge of automating variable substitution in MATLAB for this specific problem.
GreenPrint
Messages
1,186
Reaction score
0
SOLVED

Homework Statement



Hello,

I was wondering if someone could please tell what functions are required to solve this problem. I was trying to solve P*v = 1*8.314*T for T were P=[2494 1247 831 623 499 416]; and v=1:6; I was trying to come up with a series of commands that would compute the value of T and plug in the first value of P and the 1st value of v then go on to the second values, third values, fourth values... Is there any way this is possible? Note that I know how to solve the equation for T by myself but I was wondering if there was anyway I could get MATLAB to do it for me and then plug in the values on it's on and present the 6 values of temperature

Please let me know if this makes no sense, I hope it does

Code:
disp('(a)')
v=1:6;
P=[2494 1247 831 623 499 416];
temperature= @(v,P) solve('1*8.314*T-P*v','T');
temperature(v,P)

I was trying to do something like that but that obviously wouldn't work becuase solve('1*8.314*T-P*v','T'); is symbolic and I can't set it to an anonymous function and then plug in the v and P values

Homework Equations


The Attempt at a Solution

 
Last edited:
Physics news on Phys.org
Why don't you just rearrange that equation (manually) to make T the subject of the formula?
 
Back
Top