How Can MATLAB Automatically Solve and Apply Values in Equations?

Click For Summary
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 substituting elements from the arrays P and v. The proposed solution involves using MATLAB's symbolic capabilities, specifically the 'solve' function, but the user encounters issues with integrating it into an anonymous function. The final suggestion is to manually rearrange the equation to isolate T before implementing it in MATLAB.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of symbolic mathematics in MATLAB
  • Knowledge of anonymous functions in MATLAB
  • Basic algebra for rearranging equations
NEXT STEPS
  • Learn how to use MATLAB's 'solve' function for symbolic equations
  • Explore creating and using anonymous functions in MATLAB
  • Study MATLAB's array manipulation techniques for efficient calculations
  • Review algebraic methods for rearranging equations for programming applications
USEFUL FOR

Students, engineers, and researchers who need to automate mathematical calculations in MATLAB, particularly those working with symbolic equations and temperature calculations.

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?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
2
Views
2K
Replies
0
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
5K