How can I multiply an indexed vector by scalar?

1 view (last 30 days)
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 ?

Accepted Answer

Steven Lord
Steven Lord on 6 Apr 2020
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);

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!