how to fix inner matrix dimensions 3D plot?
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
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.
댓글 수: 0
채택된 답변
  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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

