how to fix inner matrix dimensions 3D plot?

I am trying to plot a 3D graph for t and T against Y_B. I would like the interval t to be 0.2 to 30 and the interval of T to be 600 to 850. Here is my code below:
T=600:1:850;
t=0.2:0.1:30;
[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/(k1-k2-k3))*(exp(-(k1+k3)*tm)-exp(-k2*tm));
Y_Bmax = max(Y_B(:));
Idx = find(Y_B(:) == Y_Bmax);
[Y_BmaxRow,Y_BmaxCol] = ind2sub(size(Y_B), Idx);
figure(1)
mesh(t,T,Y_B)
view(40, 45)
grid on
The output error tells me that the inner matrix dimensions do not agree. However, I cannot see how to fix this.

 采纳的回答

You have to do element-wise operations, so replace / with ./, and * with .* in your ‘Y_B’ calculation:
Y_B = (k1./(k1-k2-k3)).*(exp(-(k1+k3).*tm)-exp(-k2.*tm));
This expression works.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by