Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
1 view (last 30 days)
Show older comments
function T_w_bed_out = BedHex(T_bed, T_w_bed_in, m_dot_w_bed)
global U_bed A_bed
Cp_w_bed = 10^3*(-1.35090E-11*T_bed^5 + 2.40993E-08*T_bed^4 - 1.71323E-05*T_bed^3 + 6.07609E-03*T_bed^2 - 1.07591*T_bed + 8.02982E01)*1E-3;
T_w_bed_out = T_bed + (T_w_bed_in - T_bed)*exp((-U_bed*A_bed)/(m_dot_w_bed*Cp_w_bed));
So I have the above function to be called when I have to use it according to it's respective variable T_w_bedA_out or T_w_bedD_out, it seems to have the above error message as mentioned in the Summary. However, when I placed an arbituary constant eg. T_w_bedA_out = 140 (or T_w_bedD_out), the code works but it's not the desired outcome that I want.
Sorry for the inconvenience caused but I am new to MATLAB and need help in figuring out what is going on in the code. Thank you in advance!
Edit:
I have used sz = size(T_w_bedA_out) to try to see where the problem is. When the function is called, I get sz = 0 0, and I get sz = 1 1 when the arbituary constant is used.
0 Comments
Answers (1)
Walter Roberson
on 8 Dec 2022
one of the global variables is not initialized.
2 Comments
Walter Roberson
on 16 Dec 2022
Edited: Walter Roberson
on 16 Dec 2022
You do not declare the variable as global inside mainprog . You have to declare as global in every function that wants to work with the variable.
We recommend that you do not use global. See http://www.mathworks.com/help/matlab/math/parameterizing-functions.html
See Also
Categories
Find more on Naming Conventions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!