How to take the mean of matrix inside of another matrix?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
I'm trying to code G(F(x)) by putting an analytical solution inside of a numerical one. So far, I have:
nnodes = 51;
nelements = nnodes-1;
t = 0:.25:24 %time
F = zeros(length(t),nnodes)
%The first loop, over time(t) for analytical solution of F(t):
for i=1:length(t)-1;
F(i,;) = 2*t(i) %a simplifed version of the actual equation
end
%This gives a (97x51) F matrix - I know, it's quite large but necessary unless I change other variables in the code
%Second loop, where A,B and C are constants defined earlier in code
for i=1:length(t)-1;
for j = 1:nelements;
G(j) = -(A * B .* mean(mean(F(j:j+1,j:j+1)))) + C;
LocalElementMatrix = [1-G(j), -1+G(j), -1-G(j), 1+G(j)];
%Local matrix goes inside of a global element matrix
end
end
%G(j) is a (97x1) matrix
%Am I going about this the correct way? My end goal is to combine an analytical solution into a numerical one. When I set G(j) to a constant value, my local matrices and the rest of my code performs correctly, so I think it has to be an issue with the way I'm setting up G - maybe with taking the mean(mean) of F.
Any help is greatly appreciated!
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!