How can I compute and plot curves for a function

조회 수: 11 (최근 30일)
Ethan Hill
Ethan Hill 2016년 11월 2일
답변: Kushagr Gupta 2016년 11월 8일
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?

답변 (1개)

Kushagr Gupta
Kushagr Gupta 2016년 11월 8일
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!

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by