Effacer les filtres
Effacer les filtres

How to calculate Mean number and Standard Derivation?

2 vues (au cours des 30 derniers jours)
Hdez le 22 Jan 2021
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))
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:');
%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:');
%Fourier Number (fo) ----------------------------------------------
fo= alpha*dt/(h^2);
%Creation of vectors ----------------------------------------------
T= zeros (nr, nc)+20;
%Norh Boundary conditions ----------------------------------------------
for j= 1:nc
T(1,j)= 100*exp(-(j-M)^2/2*SD^2))
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?

Réponses (1)

Superficial le 22 Jan 2021
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
ans =
ans =


En savoir plus sur Preprocessing Data dans Help Center et File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by