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.

 Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 17 Août 2011

0 votes

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 commentaire

goalieman88
goalieman88 le 17 Août 2011
Thanks, I didn't know to add the periods.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by