Algorithm 1. Set time step (increment) 2. set max number of time steps 3. start with ground values of temperature at x=0, y=0, z=0, theta=0, and a particular value of fi 4. co
1 次查看(过去 30 天)
显示 更早的评论
% Corrected Code
% Initialize variables height = F2007120317S7627.Height; wind_speed = F2007120317S7627.WS; wind_direction = F2007120317S7627.WD; temperature = F2007120317S7627.Temp0; humidity = F2007120317S7627.HumiS; min_humid = max(humidity); theta_limit = 45; time_limit = 100; phi_limit = 90; delta_vx = zeros(101, 1); delta_vy = zeros(101, 1); delta_x = zeros(theta_limit, phi_limit); delta_y = zeros(theta_limit, phi_limit); delta_z = zeros(theta_limit, phi_limit); delta_theta = zeros(theta_limit, phi_limit); x = zeros(theta_limit, phi_limit); y = zeros(theta_limit, phi_limit); z = zeros(time_limit, theta_limit); % Fixed dimension delta_t = 0.1; theta_end = zeros(theta_limit + 1, phi_limit); phi = linspace(0, 2 * pi, phi_limit); theta = linspace(0, pi / 2, theta_limit); temp1 = 26.3; delta_t = 1; vx1 = 0; vy1 = 0; alti_matrix = []; vx = zeros(time_limit, theta_limit); vy = zeros(time_limit, theta_limit); cs = zeros(time_limit, theta_limit); z = zeros(time_limit, theta_limit); % Fixed dimension cs(1, :) = 331;
for i = 1:theta_limit delta_z(1, i) = z(1, i) + (cs(1, i) * cos(theta(1, i))) * delta_t; z(1, i) = delta_z(1, i); year = z(1, i); alti_matrix = [alti_matrix, year]; yr = linspace(0, 180, time_limit); altitude = 0:z(1, i):z(1, i) * 4; % alt(k,i) = altitude(1,k); temp1 = spline(height, temperature, altitude); temp_inv = temp1.'; speed1 = interp1(height, wind_speed, altitude); speed_inv = speed1.'; dir1 = interp1(height, wind_direction, altitude); dir_inv = dir1.'; vx(1, i) = speed_inv(1, 1) * cos(deg2rad(dir_inv(1, 1))); vy(1, i) = speed_inv(1, 1) * sin(deg2rad(dir_inv(1, 1))); % delta_vx(1,i) = vx(1,i) - vx(1,i); % delta_vy(1,i) = vy(1,1) - vy(1,i); humd1 = interp1(height, humidity, altitude); humd_inv = humd1.'; q(1, i) = humd_inv(1, 1) / min_humid; temp_kelvin(1, i) = (273.15 + temp_inv(1, 1)) * (1 + 0.608 * q(1, i)); cs(1, i) = 20.047 * sqrt(temp_kelvin(1, i)); % delta_cs(1,i) = cs(k+1,i) - cs(k,i); end
0 个评论
回答(1 个)
Walter Roberson
2023-9-25
编辑:Walter Roberson
2023-9-25
Remember that comments extend to the end of the physical line, not to the next semi-colon, so your comment about "Initialize variables height" is also commenting out the setting of the wind speed and height and so on that is on the same line.
We recommend against packing so much code onto each physical line: it is difficult for people to read and debug when you do that. You should break it up into separate lines such as
% Initialize variables
height = F2007120317S7627.Height;
wind_speed = F2007120317S7627.WS;
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!