How do I create a function called SolveSimult that can take 4 input arguments and output one answer?
์กฐํ ์: 1 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
I am stuck on this part of an assignment
"1) Use the measured wind speed at z = 10m and z = 40m to derive the roughness length
(z0) and assume atmospheric neutral conditions. Note that the roughness length
characterizes the upwind landscape and is thus a constant for each instance of time.
Expressions using Equation 1 can be developed as shown below for the wind speed at
both z = 10m and z= 40m. By expressing ๐๐ ( ๐ง
๐ง0
) as ln(z) โ ln(z0) and solving the 2
expressions simultaneously, the roughness length at every instance in the time series
over the 18 hours can be calculated.
๐ข(๐ง = 10) = ๐
๐ (log(10) โ log (๐ง0))
[1]
๐ข(๐ง = 40) = ๐
๐ (log(40) โ log (๐ง0))
[2]
a. Create a function called SolveSimult which will take 4 input arguments (u and z
at both 10m and 40m) and output one surface roughness length (z0). Place this
function at the end of your .m file.
b. Use SolveSimult to calculate the surface roughness length (z0) at each instance in
the time series over the 18 hours. "
This is the relevant code I have thus far for this part.
"% Step 2: Define anonymous functions
z0 = 0.05;
k = 0.4; % Karman constant
frict_v = @(u) (u*k)/(log10(10/z0));
stab_corr = @(u, f) (log10(60/z0)) - (k*u)/(f);
% Step 3: Calculate friction velocity
u10 = data(:,2);
frict_v_all = frict_v(u10);
% Step 4: Print friction velocity at 8:00
frict_v_at8u10 = frict_v(u10(49));
fprintf('The friction velocity (m/s) at 8:00 is %.3f.\n', frict_v_at8u10);
u10 = data(:,2);
u40 = data(:,3);
z10 = 10;
z40 = 40;
k = 0.4; % Karman constant"
I need you to look at the xlsx file I have attached and help me with how to solve this part. I am unsure on how to solve for the z0 by creating a function called SolveSimult. This function should be able to solve both equations for z0 at the same time. I believe the answer should be 0.321 if that helps. I would really appreciate your assistance.
๋๊ธ ์: 0
๋ต๋ณ (1๊ฐ)
Kartik
2023๋
4์ 18์ผ
Hi,
To create a function called SolveSimult that can solve the equations [1] and [2] simultaneously and output the surface roughness length (z0), you can use MATLAB's built-in function fsolve.
Here is an example implementation of the SolveSimult function:
function z0 = SolveSimult(u10, u40, z10, z40, k)
frict_v = @(u) (u*k)/(log10(z10/z0));
f10 = frict_v(u10);
f40 = frict_v(u40);
stab_corr = @(u, f) (log10(z40/z0)) - (k*u)/(f);
g = @(z0) [u10 - f10*(log10(z10/z0) + stab_corr(u10, f10)); ...
u40 - f40*(log10(z40/z0) + stab_corr(u40, f40))];
z0 = fsolve(g, 0.1);
end
To use the SolveSimult function to calculate the surface roughness length (z0) at each instance in the time series over the 18 hours, you can call it in a loop:
z0_all = zeros(size(data, 1), 1); % preallocate array
for i = 1:size(data, 1)
u10 = data(i, 2);
u40 = data(i, 3);
z0_all(i) = SolveSimult(u10, u40, z10, z40, k);
end
Note that in the example above, we assume the value of the Karman constant k and the initial value of the roughness length z0 are known. You may need to adjust these values based on your specific problem.
๋๊ธ ์: 0
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
Help Center ๋ฐ File Exchange์์ Mathematics์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!