Error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
1 次查看(过去 30 天)
显示 更早的评论
I am trying to solve this equation for h2 numerically but I keep getting the above error. Everything in the equation below is a number except for h2
T_inf1 = Tempfree1(1) ;
k1 = 167 ;
L1 = 0.0335788 ;
P1 = 0.1839468 ;
Ac1 = 0.0001333248946 ;
xfree2 = 0.0066294 ;
xfree3 = 0.0168656 ;
xfree4 = 0.031242 ;
for i = 1:length(Tempfree2)
Tb1 = Tempfree1(i) ;
Temp2_1 = Tempfree2(i) ;
syms h2
eqnfree_h2 = (Temp2_1 - T_inf1)/(Tb1 - T_inf1) == (cosh(sqrt(h2*P1/k1/Ac1)*(L1-xfree2))+(h2/sqrt(h2*P1/k1/Ac1)/k1)*sinh(sqrt(h2*P1/k1/Ac1)*(L1-xfree2)))/(cosh(sqrt(h2*P1/k1/Ac1)*L1)+(h2/sqrt(h2*P1/k1/Ac1)/k1)*sinh(sqrt(h2*P1/k1/Ac1)*L1)) ;
h_free_2(i) = vpasolve(eqnfree_h2, h2) ;
end
This is for a lab class and I making calculations based on data from a csv file
0 个评论
回答(1 个)
Jyotsna Talluri
2019-11-5
The error is because of inappropriate indexing.As you do not know the size of the result instead of assigning it to a single variable h_free_2(i)...Assign it to a vector h_free_2(i,:) .
Refer to the below link to know more about indexing.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!