MATLAB [Matlab] Plotting two functions of the same variable against each other

AI Thread Summary
The discussion revolves around the challenge of plotting two functions in MATLAB: volume as a function of time (Vc and Ve) against pressure as a function of time (P). The user is familiar with defining functions in script files but is uncertain about using function m-files for referencing. The functions are defined using anonymous functions, with Vc and Ve differing in order of magnitude. The user seeks to create two plots that will enclose an area but initially struggles with how to plot these functions against each other. A suggestion is made to plot the vectors directly, which the user acknowledges as a viable solution, highlighting that sometimes the act of asking questions can lead to self-discovery of answers.
av8or
Messages
2
Reaction score
0
I need to make two plots of volume as a function of time vs pressure as a function of time. When plotted the graph will have an enclosed area. I am having trouble on how to have MATLAB plot these two functions against each other.

My experience with MATLAB is having a function defined in a script file. I have not been exposed to using a function m file to define a function and reference it in a script.

My functions are as follows where (t) is the only variable, everything else is defined earlier in the file. I need to graph P vs Vc and P vs Ve. The order of magnitudes of Vc and Ve is different by 10^-3 hopefully that won't matter.

Vc =@(t) vc*sin(omega*t);
Ve =@(t) ve*cos(omega*t);
A =@(t) Vc(t)/(R*Tc) + vtl/(R*Ttl) + vr/(R*Tr) + Ve(t)/(R*Te);
P =@(t) M/A(t);
 
Physics news on Phys.org
av8or said:
I need to make two plots of volume as a function of time vs pressure as a function of time. When plotted the graph will have an enclosed area. I am having trouble on how to have MATLAB plot these two functions against each other.
Why not just plot the vectors against each other?
 
Simon Bridge said:
Why not just plot the vectors against each other?

I actually had that idea shortly after posting this. Thank you for your response.
 
No worries - sometimes the process of asking a question will produce the answer.
 
Back
Top