How can I compute and plot curves for a function

11 views (last 30 days)
The question is: "Compute and plot curves for dG (change in gibbs free energy) as a function of composition for a sequence of temperatures ranging from 300K-700K"
The equation is dG=X_Al*X_Zn*(9600*X_Zn+13200*X_Al)*(1-T/4000) X_Al is the composition of Aluminum; X_Zn is the composition of Zinc; T is the temperature For the composition, if Aluminum is 40% of the composition, then Zinc will be 60%, etc. Or if the composition of Zinc is 25% then the composition of Aluminum would be 75%.
How do I plot this surface?

Answers (1)

Kushagr Gupta
Kushagr Gupta on 8 Nov 2016
I understand that a surface plot needs to generated for the equation mentioned and following is one of the way in which it can be done.
The functions ' meshgrid ' and ' mesh ' can be used to plot the surface of the given equation. From the equation, as X_Al and X_Zn are interrelated they can be replaced by one variable, say X. Follow the procedure as outlined below to get the plot:
  1. Create a vector for x and t.
  2. Convert the vectors into a 2-D variables defining the relation for each point. For example, if temperature varies from 300K to 700K, we need a value of x for each temperature in that range. Similarly as x varies from 0 to 1, we need a value of t assigned to each composition in the range.
  3. Convert the equation into a MATLAB code using (dot-multiply) notation.
  4. Use the 'mesh' function to get the surface.
Following code snippet will help you get started :
x=0:0.01:1;
t=300:1:700;
[X,T]= meshgrid(x,t);
dG = X .*(1-X) .* (C.*(1-X) ...Continue the equation
mesh (X,T,dG)
Hope this helps!

Community Treasure Hunt

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

Start Hunting!