how to fix inner matrix dimensions 3D plot?

1 vue (au cours des 30 derniers jours)
sophp
sophp le 1 Fév 2018
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.

Réponse acceptée

Star Strider
Star Strider le 1 Fév 2018
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.

Plus de réponses (0)

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by