I am starting to write an .m file, and have the beginning code:
CapBasic = a0 + a1*T_evap(n) + a2*T_cond(n) + a3*T_evap(n)^2 + a4*T_evap(n)*T_cond(n) + a5*T_cond(n)^2 + a6*T_evap(n)^3 + a7*T_evap(n)^2*T_cond(n) + a8*T_evap(n)*T_cond(n)^2 + a9*T_cond(n)^3 ;
The variables T_evap and T_cond are actually an n x 1 vector, columns of data imported from Excel, with n being some very large number.
Also, I already defined the constants a0 to a9.
How can I create this new vector CapBasic since I receive the error:
"??? Undefined function or variable 'n'.
Error in ==> MTZ22JC4A_Sub at 4 CapBasic = a0 + a1*T_evap(n) + a2*T_cond(n) + a3*T_evap(n)^2 + a4*T_evap(n)*T_cond(n) + a5*T_cond(n)^2 + a6*T_evap(n)^3 + a7*T_evap(n)^2*T_cond(n) + a8*T_evap(n)*T_cond(n)^2 + a9*T_cond(n)^3 ;"
I tried to look up indices in the help but it is too confusing to figure out.
Thanks.

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 17일

0 개 추천

The message is clear. Your variable "n" is not defined. If you meant vectorization, it should be:
CapBasic = a0 + a1*T_evap + a2*T_cond + a3*T_evap.^2 + a4*T_evap.*T_cond + a5*T_cond.^2 + a6*T_evap.^3 + a7*T_evap.^2.*T_cond + a8*T_evap.*T_cond.^2 + a9*T_cond.^3

댓글 수: 1

goalieman88
goalieman88 2011년 8월 17일
Thanks, I didn't know to add the periods.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by