Why is my code returning all zeros for one of my arrays?

73 Views Asked by At

I am trying to write a code in matlab that will help me figure out the value of a variable in an equation. It is much too difficult to isolate that variable and solve for it, so I decided to try and figure it out through code. The variable represents the turbulent diffusivity coefficient within a river, so I set it equal to an array with a range of 0 to 1. I have a table of correlational values for two of the other variables in the equation. All the other variables (besides diffusivity) are constant and known from previous calculations. The equation is set to one of changing variables in the table, so I planned to set the other changing variable to a certain number in the table and see what value in the array for diffusivity returned the correlational value for the variable which the equation is set to. I have an attached a photo of the equation and the table to this post. I set t = 1 in hopes of the code returning C(x,t) = 3 for some value of epsilon (diffusivity). Equation] Table

This is the code I wrote:

clear
clc
Ma  =  9.35 * 10^12;
U = 93498.5;
x = 40233.6; 
t = 1;
epsilon =  linspace(0,1,100);
C = (Ma/(4*pi.*t.*epsilon)^0.5)*exp(-(x-(U.*t))^2/(4.*t.*epsilon));

When I ran the code and got out any formatting kinks that I could recognize, function kept returning all zeroes. I understand that the value for diffusivity may be small, but I do not think it’s so small that the code should return all zeros. Can anyone help? (I am not a great coder, pls be gentle).

0

There are 0 best solutions below