Multiply a derivative matrix with another matrix

I am trying to multiply the following matrices:
[d/dx 0; 0 d/dy; d/dy d/dx] * [N1 0 N2 0 N3 0 N4 0; 0 N1 0 N2 0 N3 0 N4]
where N1 through N4 are defined equations with systematic variables x and/or y. The output should be a 3x8 matrix.
For example, the (1,1) cell of the output should be the derivative of N1 in terms of x, the (1,3) cell should be the derivative of N2 in terms of x, etc.
How can I do this?
As a second question, I have this line of code: K=vpa(int(int(BT*E*B*t,x,x1,x2),y,y1,y2))
Without vpa, I get answers with large numbers/large numbers. To get it to show as a decimal answer, I used vpa, but now it's showing a large number of decimal places (around 15). I've tried format short, short g, short eng, etc and nothing seems to be working.
How can I get it to display less decimal places?

1 Comment

function dNdv = diffmtx(v,N)
% v -vector m x 1 - sym array
% N - matrix m x n - sym array
rz = arrayfun(@(ii)diff(N(ii,:),v(ii)),(1:numel(v)).','un',0);
dNdv = cat(1,rz{:});
end

Sign in to comment.

Answers (1)

I know of no way of dealing with your first question other than to take the derivatives of the various functions using the symbolic diff function.
The second question is easy. Specify the number of significant figures you want:
K=vpa(int(int(BT*E*B*t,x,x1,x2),y,y1,y2),5)
This will give you 5 digit results.

Asked:

on 8 Apr 2015

Commented:

on 24 Feb 2021

Community Treasure Hunt

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

Start Hunting!