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 个评论

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

请先登录,再进行评论。

回答(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.

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by