diff --git a/programming/exercises/control_structures.m b/programming/exercises/control_structures.m index 4608281..f480ef5 100644 --- a/programming/exercises/control_structures.m +++ b/programming/exercises/control_structures.m @@ -188,3 +188,38 @@ disp(x) %% 8 Teste den Zufallsgenerator +x = rand(1000,1); % some random numbers +count = zeros(5,1); +for i=1:length(x) + if(x(i) < 0.2) + count(1) = count(1) + 1; + elseif(x(i) < 0.4) + count(2) = count(2) + 1; + elseif(x(i) < 0.6) + count(3) = count(3) + 1; + elseif(x(i) < 0.8) + count(4) = count(4) + 1; + else + count(5) = count(5) + 1; + end +end +disp(count) +% Die Erwartung waere eine Gleichverteilung. + +%% 9) String parsing + +filename = '2015-10-12_100Hz_1.25V.dat'; + +% a +positions = [1]; +for i = 1:length(filename) + if filename(i) == '_' + positions = cat(1, positions, i); + end +end +positions = cat(1, positions, length(filename)) +disp(positions) + +for i = 2:length(positions) + disp(char(filename(positions(i-1):positions(i)))) +end \ No newline at end of file