Guest User

Untitled

a guest
Dec 9th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. function varargout = untitled2(varargin)
  2. % UNTITLED2 MATLAB code for untitled2.fig
  3. % UNTITLED2, by itself, creates a new UNTITLED2 or raises the existing
  4. % singleton*.
  5. %
  6. % H = UNTITLED2 returns the handle to a new UNTITLED2 or the handle to
  7. % the existing singleton*.
  8. %
  9. % UNTITLED2('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in UNTITLED2.M with the given input arguments.
  11. %
  12. % UNTITLED2('Property','Value',...) creates a new UNTITLED2 or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before untitled2_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to untitled2_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22.  
  23. % Edit the above text to modify the response to help untitled2
  24.  
  25. % Last Modified by GUIDE v2.5 30-Sep-2012 21:52:34
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name', mfilename, ...
  30. 'gui_Singleton', gui_Singleton, ...
  31. 'gui_OpeningFcn', @untitled2_OpeningFcn, ...
  32. 'gui_OutputFcn', @untitled2_OutputFcn, ...
  33. 'gui_LayoutFcn', [] , ...
  34. 'gui_Callback', []);
  35. if nargin && ischar(varargin{1})
  36. gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42. gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before untitled2 is made visible.
  48. function untitled2_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject handle to figure
  51. % eventdata reserved - to be defined in a future version of MATLAB
  52. % handles structure with handles and user data (see GUIDATA)
  53. % varargin command line arguments to untitled2 (see VARARGIN)
  54. axes(handles.Wereldkaart);
  55. % Plot de wereldkaart
  56. load('topo.mat','topo','topomap1');
  57. contour(0:359,-89:90,topo,[0 0],'b')
  58.  
  59. % Wacht op de volgende plot
  60. hold on
  61.  
  62. % Kleur de plot in
  63. image([0 360],[-90 90],topo,'CDataMapping', 'scaled');
  64. colormap(topomap1);
  65.  
  66. % Maak de assen
  67. axis equal
  68. box on
  69. set(gca,'XLim',[0 360],'YLim',[-90 90], ...
  70. 'XTick',[0 60 120 180 240 300 360], ...
  71. 'Ytick',[-90 -60 -30 0 30 60 90]);
  72.  
  73.  
  74.  
  75. %% Assen informatie
  76. title('Route geplot op de wereldkaart');
  77. xlabel('Longtitude (\circ)');
  78. ylabel('Latitude (\circ)');
  79.  
  80.  
  81. % Choose default command line output for untitled2
  82. handles.output = hObject;
  83.  
  84. % Update handles structure
  85.  
  86. % UIWAIT makes untitled2 wait for user response (see UIRESUME)
  87. % uiwait(handles.figure1);
  88.  
  89.  
  90. % --- Outputs from this function are returned to the command line.
  91. function varargout = untitled2_OutputFcn(hObject, eventdata, handles)
  92. % varargout cell array for returning output args (see VARARGOUT);
  93. % hObject handle to figure
  94. % eventdata reserved - to be defined in a future version of MATLAB
  95. % handles structure with handles and user data (see GUIDATA)
  96.  
  97. % Get default command line output from handles structure
  98. varargout{1} = handles.output;
  99.  
  100.  
  101. % --- Executes on button press in pushbutton1.
  102. function pushbutton1_Callback(hObject, eventdata, handles)
  103. [input.textnaam, input.textpad]=uigetfile('*.txt');
  104. input.pad=[input.textpad, input.textnaam];
  105. handles.current_text=input.pad;
  106.  
  107.  
  108. set(handles.edit_pad,'String',input.pad);
  109. % hObject handle to pushbutton1 (see GCBO)
  110. % eventdata reserved - to be defined in a future version of MATLAB
  111. % handles structure with handles and user data (see GUIDATA)
  112.  
  113.  
  114. % --- Executes on button press in pushbutton2.
  115. function pushbutton2_Callback(hObject, eventdata, handles)
  116. % hObject handle to pushbutton2 (see GCBO)
  117. % eventdata reserved - to be defined in a future version of MATLAB
  118. % handles structure with handles and user data (see GUIDATA)
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. % --- Executes on button press in pushbutton3.
  127. function pushbutton3_Callback(hObject, eventdata, handles)
  128.  
  129.  
  130. % hObject handle to pushbutton3 (see GCBO)
  131. % eventdata reserved - to be defined in a future version of MATLAB
  132. % handles structure with handles and user data (see GUIDATA)
  133.  
  134. Route = importdata('Route1.txt');
  135.  
  136. lon=Route(:,1); %latitude coordinaten uit txt file halen
  137. lat=Route(:,2); %longitude coordinaten uit txt file halen
  138.  
  139. for w=1:length(lon)
  140. if lon(w)<0
  141. lon(w)=lon(w)+360;
  142. end
  143. end
  144.  
  145. plot(lon,lat,'red')
  146. axes(handles.Wereldkaart)
  147.  
  148. hold on
  149.  
  150. axes(handles.axes1);
  151. % Import data
  152. data=importdata('data_1.txt');
  153.  
  154. data_1=data;
  155.  
  156.  
  157. % Make grid
  158. for i=1:360
  159. for j=1:180
  160. a=((i-1)*180)+j;
  161. data(a,2)=data(a,2)+90;
  162. end
  163. end
  164.  
  165. for i=1:360
  166. for j=1:180
  167. a=((i-1)*180)+j;
  168. data_raw(i,j)=data(a,3);
  169. end
  170. end
  171.  
  172. data_2=data_raw;
  173.  
  174. % Plot data
  175. title('Raw Data')
  176. surf(data_raw);
  177. hold off
  178.  
  179.  
  180. % --- Executes on button press in pushbutton4.
  181. function pushbutton4_Callback(hObject, eventdata, handles)
  182. % hObject handle to pushbutton4 (see GCBO)
  183. % eventdata reserved - to be defined in a future version of MATLAB
  184. % handles structure with handles and user data (see GUIDATA)
  185. % Clean NaN
  186.  
  187. global data_raw;
  188. axes(handles.axes1)
  189. for i=2:360
  190. for j=2:180
  191.  
  192. if isnan(data_raw(i,j))
  193. if j<2
  194. data_raw(i,j)=data_raw(i-1,j);
  195. end
  196. if j>1
  197. data_raw(i,j)=data_raw(i,j-1);
  198. end
  199. end
  200. end
  201. end
  202.  
  203.  
  204. %% Peaks and Valleys
  205.  
  206. d=data_raw; %
  207.  
  208. % Maximum deviation
  209. dev=0.05;
  210.  
  211. % Clean data
  212. for i=1:360
  213. for j=1:180
  214.  
  215. if i==1
  216.  
  217. if j>2
  218. if (d(i,j)<d(i,j-2)*(1-dev))|(d(i,j)>d(i,j-2)*(1+dev))
  219. d(i,j)=2*d(i,j-1)-d(i,j-2);
  220. end
  221. end
  222.  
  223. end
  224.  
  225. if i==2
  226.  
  227.  
  228. if j>2
  229. if (d(i,j)<d(i,j-2)*(1-dev))|(d(i,j)>d(i,j-2)*(1+dev))
  230. d(i,j)=2*d(i,j-1)-d(i,j-2);
  231. end
  232. end
  233.  
  234. end
  235.  
  236. if i>2
  237.  
  238. if j<3
  239. if (d(i,j)<d(i-2,j)*(1-dev))|(d(i,j)>d(i-2,j)*(1+dev))
  240. d(i,j)=(2*d(i-1,j))-d(i-2,j);
  241. end
  242. end
  243.  
  244. if j>2
  245. if (d(i,j)<d(i-2,j)*(1-dev))|(d(i,j)>d(i-2,j)*(1+dev))
  246. d(i,j)=((2*d(i,j-1)-d(i,j-2))+(2*d(i-1,j)-d(i-2,j)))/2;
  247. end
  248. end
  249.  
  250. end
  251.  
  252. end
  253. end
  254.  
  255. data_clean=d;
  256. % Plot data
  257. title('Clean Data')
  258. surf(data_clean);
  259.  
  260.  
  261.  
  262.  
  263. function edit_pad_Callback(hObject, eventdata, handles)
  264. % hObject handle to edit_pad (see GCBO)
  265. % eventdata reserved - to be defined in a future version of MATLAB
  266. % handles structure with handles and user data (see GUIDATA)
  267.  
  268. % Hints: get(hObject,'String') returns contents of edit_pad as text
  269. % str2double(get(hObject,'String')) returns contents of edit_pad as a double
  270.  
  271.  
  272. % --- Executes during object creation, after setting all properties.
  273. function edit_pad_CreateFcn(hObject, eventdata, handles)
  274. % hObject handle to edit_pad (see GCBO)
  275. % eventdata reserved - to be defined in a future version of MATLAB
  276. % handles empty - handles not created until after all CreateFcns called
  277.  
  278. % Hint: edit controls usually have a white background on Windows.
  279. % See ISPC and COMPUTER.
  280. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  281. set(hObject,'BackgroundColor','white');
  282. end
  283.  
  284.  
  285.  
  286. function edit2_Callback(hObject, eventdata, handles)
  287. % hObject handle to edit2 (see GCBO)
  288. % eventdata reserved - to be defined in a future version of MATLAB
  289. % handles structure with handles and user data (see GUIDATA)
  290.  
  291. % Hints: get(hObject,'String') returns contents of edit2 as text
  292. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  293.  
  294.  
  295. % --- Executes during object creation, after setting all properties.
  296. function edit2_CreateFcn(hObject, eventdata, handles)
  297. % hObject handle to edit2 (see GCBO)
  298. % eventdata reserved - to be defined in a future version of MATLAB
  299. % handles empty - handles not created until after all CreateFcns called
  300.  
  301. % Hint: edit controls usually have a white background on Windows.
  302. % See ISPC and COMPUTER.
  303. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  304. set(hObject,'BackgroundColor','white');
  305. end
Add Comment
Please, Sign In to add comment