Azzera filtri
Azzera filtri

how to fix inner matrix dimensions 3D plot?

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 1 Feb 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.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by