MATLAB: How to make the dimensions agree for this function MATLABmatrix 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. Best Answer f = @(x) x.' - exp(cos([1:4]*sum(x))) Related SolutionsMATLAB: How do you write the equation f=exp(x)*cos(x) I am guessing you want to use the element-wise multiply operator, which has the dot:f = exp(x) .* cos(x); MATLAB: How to make a 3×3 matrix a 9×1 matrix reshape(x,9,1)or x(:) % this creates a column vector out of a matrix Related QuestionIndex exceeds matrix dimensions.Matrix dimensions must agree.
Best Answer