MATLAB: How to calculate the first derivative of a vector with respect to a matrix matrixvector I have x = a*B*C, where x is 1*4 vector, a is 1*2 vector, B is 2*4 matrix, and C is 4*4 matrix. How can I calculate the first derivative of the vector x with respect to matrix B? Best Answer syms a [1 2]syms B [2 4]syms C [4 4]x = a*B*C;derivs = arrayfun(@(X) reshape(gradient(X, B(:)),size(B)), x, 'uniform', 0); Related SolutionsMATLAB: How to get the positive root of the cubic a*x^3+3*b*x^2+3*c*x+d=0 You can tryb = .1:.1:2;a = 1;c = b+2;d = -3;posR = zeros(1,length(b));for i = 1:length(b) r = roots([a,3*b(i),3*c(i),d]); posR(i) = r(r>0); % only one real root for the values you specified posR(i) = posR(i)/(posR(i)+1);end MATLAB: Calculating derivative of a function syms xa=62;b=95;y = (3*x.^2.*sin(a*x))./(x.^2+b);dy = diff(y) Related QuestionPlotting with respect to time
Best Answer