MATLAB: How to multiply an indexed vector by scalar

indexindexingMATLABvector

I have a vector B_ j that is twice phi_i :
and
phi_i = @(ii, m) atan( d + (ii*d)./m) ;
Why I can not write B_j = 2.*phi_i ?

Best Answer

phi_i is a function, not an array. You could write B_j as the product of a number and the value you obtained from evaluating phi_i:
phi_i = @(ii, m) atan( d + (ii*d)./m);
B_j = 2*phi_i(1:10, 2)
Or you could write B_j as a function of ii and m, like phi_i is:
B_j = @(ii, m) 2*phi_i(ii, m);