フィルターのクリア

how to fix inner matrix dimensions 3D plot?

1 回表示 (過去 30 日間)
sophp
sophp 2018 年 2 月 1 日
回答済み: Star Strider 2018 年 2 月 1 日
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.

採用された回答

Star Strider
Star Strider 2018 年 2 月 1 日
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 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by