How to apply an equation to each element in the array?

조회 수: 7 (최근 30일)
KarolN
KarolN 2021년 11월 27일
댓글: KarolN 2021년 11월 28일
I have an equation:
Which I need to apply to every element in a 10x10 matrix of u.
u - a node in numerical model of rock layer
j,n - indexes of movement
The matrix is supposed to have identical starting values of 80.

채택된 답변

Matt J
Matt J 2021년 11월 27일
conv( u , [0 1 0]+alpha*[1 -2 1] )
  댓글 수: 5
Matt J
Matt J 2021년 11월 28일
Use conv2 instead
soilSub = conv2( u, [0 1 0]+alpha*[1 -2 1] )
KarolN
KarolN 2021년 11월 28일
IT WORKS! Thank you very much for your valuable advice!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 11월 28일
Try conv2():
k = 10^-7 % filtration of soil
M = 19000
q = 80 % external force Q acting on soil
DeltaZ = 0.1 % depth of soil subsidization
GammaW = 10 % water weight [Kn/m^3]
Cv = k*M/GammaW % consolidation factor
DeltaT = DeltaZ^2/(2*Cv) % max iteration step
alpha = Cv*DeltaT/DeltaZ^2
% NUMERICAL PARAMETERS
u = q*ones(10:10) % matrix of u nodes
% SOLUTION
kernel = [0, 1, 0] + alpha * [1, -2, 1]
% Discrete form of the governing equation:
soilSub = conv2(u, kernel) % Use conv2(), not conv()
  댓글 수: 4
Image Analyst
Image Analyst 2021년 11월 28일
No problem. I'm sure using conv() instead of conv2() was just an oversight by Matt. I know he knows better - he's a bright guy. You can vote for multiple answers though you can only Accept one. You can even vote for one you Accepted to award double the reputation points to that one.
KarolN
KarolN 2021년 11월 28일
And so additionally I learned about that vote feat :) Voted for both of you naturally. Thanks guys

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by