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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 1 Dez. 2014
Bearbeitet: Azzi Abdelmalek am 1 Dez. 2014
f = @(x) x.' - exp(cos([1:4]*sum(x)))

2 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by