Effacer les filtres
Effacer les filtres

How to take the mean of matrix inside of another matrix?

2 vues (au cours des 30 derniers jours)
DrWooo
DrWooo le 18 Avr 2017
Modifié(e) : DrWooo le 18 Avr 2017
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!

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by