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 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by