Rainfall qwerty

Version 1.0.0 (1.39 KB) by Mark
Rainfall
0 Downloads
Updated 9 Oct 2023

View License

function [time, position] = simulateBouncingBall(hstart, loss, timeSteps, dt)
% Input:hstart, loss, timeSteps, dt
% Output:[time, position]
% Initialize arrays to store time and position data
time = zeros(1, timeSteps);
position = zeros(1,timeSteps);
% Initialize initial conditions
height = hstart; % Initial height
velocity = 0; % InitiasimulateBouncingBall(1,0.211,1000,0.01) velocity
g = 9.81; % Acceleration due to gravity (m/s^2)
% Simulation loop
for step = 1:timeSteps
% Record current time and position
time(step) = step * dt;
position(step) = height;
% Update velocity and position using physics equations
velocity = velocity - g * dt;
height = height + velocity * dt;
% Check for collision with the ground
if height <= 0
% Handle the bounce
velocity = -velocity * (1 - loss);
height = 0;
% Check if the maximum bounce height is less than 30% of initial height
if abs(velocity) < sqrt(2 * hstart * g) * 0.3
break; % Exit the simulation loop
end
end
% Check if the ball has come to rest (velocity close to zero)
if abs(velocity) < 1e-6
break; % Exit the simulation loop
end
% Trim the arrays to remove unused elements
time = time(1:step);
position = position(1:step);
end
% Plot the results
figure;
plot(time, position);
xlabel('Time (s)');
ylabel('Position (m)');
title('Bouncing Ball Simulation');
grid on;
end
% Auteur:
% Datum:
clc
close all
clear all
% Read data
rain_table = readtable('rainfall_Groningen.txt');
% Calculate plot
figure;
plot(rain_table.DateTime, rain_table.Expectation6hour, 'b', 'LineWidth', 1.5);
hold on;
plot(rain_table.DateTime, rain_table.low_50_band, 'r--', 'LineWidth', 1);
plot(rain_table.DateTime, rain_table.high_50_band, 'g--', 'LineWidth', 1);
% Data voor de x-as
dates = rain_table.DateTime;
title('Voorspelde neerslag in Groningen (mm/6 uur)');
xlabel('Datum');
ylabel('Neerslag (mm/6 uur)');
xticks(dates);
xtickangle(45);
datetick('x', 'yyyy-mm-dd');
legend('Voorspelling', 'Ondergrens (50%)', 'Bovengrens (50%)');
grid on;
set(gca, 'XTick', dates(1:1:end));
set(gca, 'YTick', 0:0.1:max(rain_table.high_50_band));
axis tight;
% Stap 3: Vind datums zonder voorspelde neerslag
dry_dates = dates(rain_table.Expectation6hour == 0);

Cite As

Mark (2024). Rainfall qwerty (https://www.mathworks.com/matlabcentral/fileexchange/136349-rainfall-qwerty), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0