How to calculate Mean number and Standard Derivation?

1 次查看(过去 30 天)
Hello everyone, I have to do a 2D Diffusion Equation model using the Explicit Finite Difference Method.
To calculate the North Boundary Condition I have to use I have to use the Gaussian Boundary Distribution of temperatures of amplitude 100 degrees, which I have done the for loop for the north boundary condition with the formula: T(1,j)= 100*exp(-(j-M)^2/2*SD^2))
clc
close all
clear all
%Lenght of the plate ----------------------------------------------
lx= input ('Enter the desire value for x length:');
ly= input ('Enter the desire value for y length:');
%alpha ------------------------------------------------------------
k=143; %Thermal coductivity (W/m.C)
p=2.8*10^3; %Density (kg/m^3)
c=795; %Specific heat (J/kg.C)
alpha= k/(p*c); %Thermal diffusivity (m^2/s)
%Grid Spacing
h= input('Enter the desire grid spacing:');
while rem (lx,h)~=0 || rem (ly,h)~=0
fprintf ('Incorrect solution \n Please enter a value which results in an integer number:')
h= input ('Reenter the desire grid spacing:');
end
%Grid Spacing along lx and ly -------------------------------------
nc= (lx/h)+1; %Number of columns
nr= (ly/h)+1; %Number of raws
%Time step --------------------------------------------------------
dt= input ('Enter the desire time step:');
while dt>= h^2/(4*alpha)
fprintf('solution is unstable. Please return to dt and choose a smaller value for: %g\n', h^2/(4*alpha))
dt= input ('Enter the desire time step:');
end
%Fourier Number (fo) ----------------------------------------------
fo= alpha*dt/(h^2);
%Creation of vectors ----------------------------------------------
t=0
T= zeros (nr, nc)+20;
%Norh Boundary conditions ----------------------------------------------
for j= 1:nc
x=(j-1)/(nc-1)
T(1,j)= 100*exp(-(j-M)^2/2*SD^2))
end
However, before de for loop, I would need to calculate M (Mean Number) and SD (Standard Derivation) but I have no idea how to do it. Can someone help me please?

回答(1 个)

Superficial
Superficial 2021-1-22
You don't say what you need the mean or SD of.
But in general, if you want the mean of a vector (a list of numbers), then you can :
vec=[5 5 20] % any numbers you like
vec =
5 5 20
mean(vec)
ans =
10
std(vec)
ans =
8.6603

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by