I am attempting to plot a mesh 3D graph that displays how Y_B varies with t and T. I then want to solve this graph to find the coordinates that gives the maximum value of Y_B. This is the code to give a graph that displays how T varies with Y_B for different variables for t
if true
% code
T=600:10:850;
t = 1;
k1 = 10^7.*exp(-12700./T);
k2 = 5*10^4.*exp(-10800./T);
k3 = 7*10^7.*exp(-15000./T);
t=1:2:20;
hold on;
for i=1:numel(t)
Y_B = (k1.*t(i).*(k1+k3))./(((k2.*t(i))+1).*(k1+k3).*(1+(t(i).*(k1+k3))));
plot(T,Y_B);
end
How do I transform this into a 3D plot for t = 0.2:20 and T = 600:850

댓글 수: 2

Star Strider
Star Strider 2018년 1월 31일
What is ‘T’?
What is its range?
How does it enter into the calculation of ‘Y_B’?
sophp
sophp 2018년 1월 31일
T changes the value of k1, k2 and k3
k1 = 10^7.*exp(-12700./T);
k2 = 5*10^4.*exp(-10800./T);
k3 = 7*10^7.*exp(-15000./T);
Its range is 600 to 850
Y_B is given by
Y_B = (k1.*t.*(k1+k3))./(((k2.*t+1).*(k1+k3).*(1+(t.*(k1+k3))));
The range of t is 0.2 to 20

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2018년 1월 31일

0 개 추천

Use meshgrid to create matrices for ‘t’ and ‘T’, and remove the subscripts from the ‘Y_B’ calculation:
T=600:10:850;
t=1:2:20;
[tm,Tm] = meshgrid(t, T);
k1 = 10^7.*exp(-12700./Tm);
k2 = 5*10^4.*exp(-10800./Tm);
k3 = 7*10^7.*exp(-15000./Tm);
Y_B = (k1.*tm.*(k1+k3))./(((k2.*tm)+1).*(k1+k3).*(1+(tm.*(k1+k3))));
figure(1)
surf(t,T,Y_B)
grid on
xlabel('t')
ylabel('T')
zlabel('Y\_B')

댓글 수: 4

sophp
sophp 2018년 1월 31일
Thanks Star Strider! I found another question you answered regarding finding the maximum point for a 3D plot. Using your code, but changing the variables
Y_Bmax = max(Y_B(:));
[Y_Bmax,Idx] = max(Y_B(:));
[Y_BmaxRow,Y_BmaxCol] = ind2sub(size(Y_B), Idx);
However it is not printing the indices of the maximum plot. It may be the case that the max value of Y_B occurs at a range of values. Is there a function which tells me these values?
As always, my pleasure!
There seems to be only one maximum. (I used find here to be sure.) It plots as a solid red upward-pointing triangle with this code:
Y_Bmax = max(Y_B(:));
Idx = find(Y_B(:) == Y_Bmax);
[Y_BmaxRow,Y_BmaxCol] = ind2sub(size(Y_B), Idx);
figure(1)
surf(t,T,Y_B)
hold on
plot3(tm(Y_BmaxRow,Y_BmaxCol), Tm(Y_BmaxRow,Y_BmaxCol), Y_B(Y_BmaxRow,Y_BmaxCol), '^r', 'MarkerFaceColor','r')
hold off
grid on
xlabel('t')
ylabel('T')
zlabel('Y\_B')
view(40, 45)
To use my code to plot the maximum, it is necessary to use the matrix arguments ‘tm’ and ‘Tm’ in the plot3 call, not the vectors that created them.
sophp
sophp 2018년 1월 31일
I see. This works perfectly, how do I display these coordinates??
I would do this:
DisplayCoordinates = [tm(Y_BmaxRow,Y_BmaxCol), Tm(Y_BmaxRow,Y_BmaxCol), Y_B(Y_BmaxRow,Y_BmaxCol)]
DisplayCoordinates =
19.0000 710.0000 0.5114

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2018년 1월 31일

댓글:

2018년 1월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by