How can I make the dimensions agree for this function

f = @(x) x - exp(cos(transpose[1:4])*sum(x)); And x=[2.5;2;1.4;.9] is a column vector. when I subtract it says error Matrix dimensions must agree.

2 Comments

After editing your question you made errors
Should it be: f = @(x) x - exp(cos(transpose([1:4]))*sum(x))

Sign in to comment.

 Accepted Answer

f = @(x) x.' - exp(cos([1:4]*sum(x)))

2 Comments

f = @(x) x - exp(cos([1:4]')*sum(x));
x=[2.5;2;1.4;.9]
f(x)
Thanks, it works now!

Sign in to comment.

More Answers (0)

Products

Tags

Asked:

on 1 Dec 2014

Commented:

on 1 Dec 2014

Community Treasure Hunt

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

Start Hunting!