Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function varargout = zad_4(varargin)
- % ZAD_4 MATLAB code for zad_4.fig
- % ZAD_4, by itself, creates a new ZAD_4 or raises the existing
- % singleton*.
- %
- % H = ZAD_4 returns the handle to a new ZAD_4 or the handle to
- % the existing singleton*.
- %
- % ZAD_4('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in ZAD_4.M with the given input arguments.
- %
- % ZAD_4('Property','Value',...) creates a new ZAD_4 or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before zad_4_OpeningFcn gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to zad_4_OpeningFcn via varargin.
- %
- % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
- % instance to run (singleton)".
- %
- % See also: GUIDE, GUIDATA, GUIHANDLES
- % Edit the above text to modify the response to help zad_4
- % Last Modified by GUIDE v2.5 30-May-2016 18:15:49
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @zad_4_OpeningFcn, ...
- 'gui_OutputFcn', @zad_4_OutputFcn, ...
- 'gui_LayoutFcn', [] , ...
- 'gui_Callback', []);
- if nargin && ischar(varargin{1})
- gui_State.gui_Callback = str2func(varargin{1});
- end
- if nargout
- [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
- else
- gui_mainfcn(gui_State, varargin{:});
- end
- % End initialization code - DO NOT EDIT
- function zad_4_OpeningFcn(hObject, eventdata, handles, varargin)
- handles.output = hObject;
- guidata(hObject, handles);
- % city Kamennomostskiy
- lat = 44.300703;
- lon = 40.183990;
- terrain = getTerrain(lat,lon);
- minHeight = -499;
- maxHeight = 3500;
- colMat = [
- 0.0 0.0 0.7
- 0.0 0.8 0.0
- 0.0 1.0 0.0
- 1.0 1.0 0.0
- 1.0 0.8 0.0
- 1.0 0.0 0.0
- 0.7 0.0 0.0
- 0.4 0.0 0.0 ];
- delta = 0.8365;
- lat_s = lat - delta;
- lon_s = lon - delta;
- latPoints = [ceil(lat) floor(lat)];
- lonPoints = [floor(lon) ceil(lon)];
- lat_diff = 201-(latPoints - lat_s)*100/delta;
- lon_diff = (lonPoints - lon_s)*100/delta;
- axes(handles.axes1);
- imagesc(terrain, [minHeight maxHeight]);
- colormap(colMat);
- colorbar;
- xLabelName='Longitude °';
- yLabelName='Latitude °';
- xlabel(xLabelName);
- ylabel(yLabelName);
- set(gca,'XGrid','on','YGrid','on','XTickLabel',lonPoints,'XTick',lon_diff,'YTickLabel',latPoints,'YTick',lat_diff);
- hold on;
- plot(101,101,'ko');
- text(105,101,'Kamennomostskiy','Color','Black');
- % --- Outputs from this function are returned to the command line.
- function varargout = zad_4_OutputFcn(hObject, eventdata, handles)
- % varargout cell array for returning output args (see VARARGOUT);
- % hObject handle to figure
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Get default command line output from handles structure
- varargout{1} = handles.output;
- function terrain = getTerrain(lat, lon)
- pixelsPerDegree = 120;
- columns = 4800;
- dLAT = 90 - lat;
- dLON = 20 + lon;
- x = round(dLON * pixelsPerDegree) - 100;
- y = round(dLAT * pixelsPerDegree) - 100;
- f = fopen('E020N90.DEM', 'r');
- terrain = zeros(201, 201, 'double');
- for i = 1 : 201
- fseek(f, ((y + i) * columns + x ) * 2, 'bof');
- terrain(i, :) = fread(f, 201, 'int16', 0, 'b');
- end
- fclose(f);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement