matlab - Cannot use operator ^ on a vector value -


function[df] = getdiscountfactor(t,t,r,i) y=getyearfraction(t,t); a=r(i,1) df=1/((1+a)^y); end 

this code, thing y cannot (1+a)^y operation because says it's vector, vector value r(i,1). when call in command line prints 0.03 , shows error

a =      0.0300  error using  ^  inputs must scalar , square matrix. compute elementwise power, use power (.^) instead. 

if use .^ operator problem solved df gets vector , need single number.

you've checked first input see it's scalar, presumably means other input, y, not square matrix. if check y too, see what's gone wrong.

and if not, matlab have function tells type matlab thinks object is? run on a , on y. or pedantic, run on 1+a. should clear things up.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -