solutions for control_structures
This commit is contained in:
		
							parent
							
								
									5027e8a097
								
							
						
					
					
						commit
						70d7d81562
					
				| @ -188,3 +188,38 @@ disp(x) | |||||||
| 
 | 
 | ||||||
| %% 8 Teste den Zufallsgenerator | %% 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 | ||||||
		Reference in New Issue
	
	Block a user