Programovanie geofyzikálnych úloh v prostredí MATLAB

Programovanie geofyzikálnych úloh v prostredí MATLAB

Programovanie geofyziklnych loh v prostred MATLAB LS 2015, 3.stretnutie Programovanie geofyziklnych loh v prostred MATLAB Program predmetu: 1. tde: organizan pokyny, intalcia softvru, vod, voba rieenho problmu, zkladn info o Matlabe, pracovn prostredie Matlabu 2. tde: zkladn opercie s maticami, import a export dt, zkladn grafick zobrazovanie (grafy a mapy) 3. tde: pokroilejie grafick zobrazovanie (popis grafov a mp, 3D grafy) 4. tde: prkazy, stavba programov

5. tde: stavba programov, tvorba M-sborov 6. tde: funkcie zabudovan v Matlabe, tvorba vlastnch funkci 7. tde: prklady programovania geofyziklnych (geologickch) loh 8. tde: prklady programovania geofyziklnych (geologickch) loh 9. tde: tvorba vlastnch aplikci, prca s GUI (Graphical User Interface) 10. tde: tvorba vlastnch aplikci, nstroj GUIDE pozn.: zmeny vyhraden Programovanie geofyziklnych loh v prostred MATLAB natanie matc zo sborov (najjednoduchie, ASCII): vyuitie prkazov: dlmread(nzov sboru,delimiter) importdata(nzov sboru,delimiter); prklad: natanie profilovch dt x a dT do dvoch jednoriadk. matc

clear all, close all; clc; % INPUT OF PROF. DATA - from 2 columns file (into matrix inpXdT) inpXdT = dlmread('mod1b.dat',' '); % columns are separated into one-column vectors X and dT X=inpXdT(:,1); dT=inpXdT(:,2); % number of readed data-rows is determined - put into m m = numel(X) % plotting the graph of input data plot(X,dT); Programovanie geofyziklnych loh v prostred MATLAB natanie matc zo sborov (sofistikovanejie, ASCII): prkazy fopen() a fclose(): fid = fopen(filename) alebo

fid = fopen(filename, permission) fid skalrna hodnota (file identifier), 1: spen otvorenie 1.sboru, 2: druhho, ... -1: nespen otvorenie sboru permission argument, definujci monosti prce so sborom Programovanie geofyziklnych loh v prostred MATLAB natanie matc zo sborov (troku zloitejie, ASCII): pozn.: Pri prci so sbormi je vemi uiton prkaz uigetfile(): [fname,pname] = uigetfile('koncovka','nzov okna'); Sli na na zskanie mena sboru , otvor windovsovsk okno a ukazuje cestu k sboru. Po realizcii ulo v premennej

fname nzov sboru a pname cestu k nemu prklad: [fname,pname] = uigetfile('*.grd','input of data (grid)'); Programovanie geofyziklnych loh v prostred MATLAB po prkaze fopen() nasleduje samotn natanie prvkov sboru: tline = fgetl(fid) nata textov riadok do premennej tline (podobn je fgets(), ale ten nata aj znak novho riadku /newline character/, fgetl() tento znak ignoruje) alebo A = fscanf(fid, format) alebo A = fscanf(fid, format, size) nata formtovan daje zo sboru

format typu %znak, napr.: %e, %f, %g Floating-point numbers %c Sequence of characters; number specified by field width %d Base 10 integers %i Defaults to base 10 integers. Data starting with 0 is read as base 8 %o Signed octal integer %s A series of non-white-space characters %u Signed decimal integer %x Signed hexadecimal integer Programovanie geofyziklnych loh v prostred MATLAB natanie matc zo sborov (troku zloitejie, ASCII): po prkaze fopen() nasleduje samotn natanie prvkov sboru: prklad: [A,count] = fscanf(fid,'%f',[rowsm,columnsn]);

nata do matice A hodnoty z otvorenho sboru s identifiktorom fid ako relne premenn (floating point numbers), priom rozmer matice je dan premennmi rowsm a columnsn na zver prce so sborom mus by vdy prkaz fclose(): status = fclose(fid) alebo status = fclose('all') status 0 (spen zatvorenie sboru) -1 (nespen zatvorenie sboru) Programovanie geofyziklnych loh v prostred MATLAB

natanie matc zo sborov (troku zloitejie, ASCII): alie monosti (natania textovho sboru): textread, textscan, ... (vi. help Matlabu) prca s binrnymi sbormi: A = fread(fid) %nata binrne daje zo sboru Programovanie geofyziklnych loh v prostred MATLAB alie uiton prkazy (svisia s natanm dajov zo sboru, prca s reazcami, reazec je postupnos po sebe idcich znakov):

strtok() vyberie as reazca, ktor je od zvyku oddelen medzerou [token, remain] = strtok('str br') : z reazca 'str br vyberie prv as 'str ') do premennej token a druh as 'br ' do premennej remain (oddelen s v 'str br medzerou) prklad: cele_meno = 'Janko Mrkvicka'; [prve_meno, priezvisko] = strtok(cele_meno); prve_meno priezvisko pozn.: vimnite si teraz farbu znakov reazca v Command Windov a symboly pre premenn v okne Workspace Programovanie geofyziklnych loh v prostred MATLAB alie uiton prkazy

(svisia s natanm dajov zo sboru, prca s reazcami): str2double() pretransformuje reazec na slo s presnosou double X = str2double('str'): pretransformuje reazec 'str' na slo s presn. double a umiestni ho do premennej (matice) X prklad: nacitane_cislo = '52'; X = str2double(nacitane_cislo); Programovanie geofyziklnych loh v prostred MATLAB natanie SRF gridu (ASCII format) zo sboru do matice: rowsm = 0; columnsn = 0; minx = 0; maxx= 0; miny = 0; maxy= 0; minf = 0; maxf= 0; [fname,pname] = uigetfile('*.grd','input of data (Surfer ASCII *.grid file)'); fid = fopen(fname,'r'); % reading of the GS ASCII grid header (rows, columns, minx, maxx, miny, maxy, minf, maxf)

tline = fgetl(fid); row1 = tline; tline = fgetl(fid); row2 = tline; [token,rem] = strtok(row2); rowsm = str2double(token); columnsn = str2double(rem); tline = fgetl(fid); row3 = tline; [token,rem] = strtok(row3); minx = str2double(token); maxx = str2double(rem); tline = fgetl(fid); row4 = tline; [token,rem] = strtok(row4); miny = str2double(token); maxy = str2double(rem); tline = fgetl(fid); row5 = tline; [token,rem] = strtok(row5); minf = str2double(token); maxf = str2double(rem); % reading of the main field of the grid - into the matrix A [A,count] = fscanf(fid,'%f',[rowsm,columnsn]); status = fclose(fid); field = A'; % size of the readed matrix: columnsn x rowsm [columnsn,rowsm] = size(A); s = [' size of readed grid: ' int2str(rowsm) ' rows x ' int2str(columnsn) ' columns

msgbox(s,'message'); contour(field); Programovanie geofyziklnych loh v prostred MATLAB, LS 2012 poznmky ku grafike: aktvne okno pri kreslen (okno, do ktorho Matlab realizuje aktulny grafick prkaz): - okno, v ktorom bol realizovan posledn grafick prkaz - okno, uren prkazom figure alebo figure(slo) - okno, na ktor uvate klikol myou Programovanie geofyziklnych loh v prostred MATLAB 2D grafika: zkladn prkaz plot():

plot(Y); %zobraz Y voi poradovmu islu prvku matice plot(X1,Y1,...); % zobraz Y1 voi X1 plot(X1,Y1,X2,Y2,...); % zobraz 2 grafy do jednho plot(X1,Y1,LineSpec,...); %definujeme tl iary plot(...,'PropertyName',PropertyValue,...); skratky pre farby: 1. 2. prklady: x = -pi:.1:pi; y = sin(x); plot(x,y); x = -pi:pi/10:pi; y = tan(sin(x)) - sin(tan(x));

% nastavenie roznych parametrov ciar plot(x,y,'--rs','LineWidth',2, ... 'MarkerEdgeColor','k',... 'MarkerFaceColor','g',... 'MarkerSize',5); Programovanie geofyziklnych loh v prostred MATLAB 2D grafika: popis os a grafov: axis([minx maxx miny maxy]); - definovanie rozsahov os xlabel(popis,FontSize,number); - popis osi x ylabel(popis,FontSize,number); - popis osi y legend('popis1'); - popis grafu grid on; - poloenie siete set(H,'PropertyName',PropertyValue,...) - nastavenie iarok (ticks) a

popisov iarok (labels) Tieto prkazy je mon realizova aj dodatone (u po nakreslen samotnho grafu) s doplovan v aktvnom okne. prklad.: axis([min(x) max(x) min(y) max(y)]); xlabel('x [m]','FontSize',10); ylabel('z[m]','FontSize',10); legend('graf'); grid on; set(gca,'XTick',-pi:pi/2:pi); %umiestni ticks s krokom pi/2 od pi po +pi set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'}); %pope tieto ticks Programovanie geofyziklnych loh v prostred MATLAB 2D grafika sumarizcia grafov: plot(x,y) klasick iarov graf

plotyy(x1,y1,x2,y2) dva grafy v jednom s popisom os naavo a napravo plot3(x,y,z) iarov graf v priestore bar(x,y) stpcov graf stem(x,y) graf izolovanch bodov loglog(x,y) graf s osami v log10 mierkach semilogy(x,y) y-ov os v log10 mierke semilogx(x,y) x-ov os v log10 mierke Programovanie geofyziklnych loh v prostred MATLAB plot3(x,y,z) iarov graf v priestore prklad - pirla: close all; clear all; clc; t = 0:pi/50:10*pi; plot3(sin(t),cos(t),t); grid on; axis square; % bez tohto prkazu by zostala vertiklna os sploten

bar(x,y) stpcov graf prklad: close all; clear all; clc; t = 0:pi/30:2*pi; y = sin(2*t) + cos(5*t); bar(t,y); stem(x,y) graf izolovanch bodov prklad: close all; clear all; clc; t = 0:pi/30:pi/2; y = sin(2*t) + cos(5*t); stem(t,y); Programovanie geofyziklnych loh v prostred MATLAB loglog(x,y) graf s osami v log10 mierkach prklad:

close all; clear all; clc; x = logspace(-1,2); %vytvor x v log10 mierke od -1 do 2 loglog(x,exp(x)); grid on; semilogy(x,y) y-ov os v log10 mierke prklad: close all; clear all; clc; x = 0:.1:10; semilogy(x,10.^x); grid on; semilogx(x,y) x-ov os v log10 mierke podobne... Programovanie geofyziklnych loh v prostred MATLAB

2D grafika: prkaz contour(): contour(Z) contour(Z,n) contour(Z,v) contour(X,Y,Z) contour(X,Y,Z,n) contour(X,Y,Z,v) contour(...,LineSpec) contour(ax,...) a jemu podobn prkazy: contourf(Z); % vyplnen izoiary contour3(Z); % izoiary v 3D pohade

contourslice(x,y,z) izoiary v rezoch v priestore image(Z); % farebn image mapa, POZOR! Rozdielne definovan poiatok surf(X,Y,Z); %priestorov plocha Programovanie geofyziklnych loh v prostred MATLAB 2D grafika: prkaz contour(): contour(Z) contour(Z,n) contour(Z,v) contour(X,Y,Z) contour(X,Y,Z,n) contour(X,Y,Z,v) contour(...,LineSpec)

contour(ax,...) popis izoiar: prkaz set() nastavenie grafickch parametrov prklad: clear all; close all; clc; X,Y] = meshgrid(-2:.2:2,-2:.2:3); Z = X.*exp(-X.^2-Y.^2); C,h] = contour(X,Y,Z); %returns contour matrix C and a handle h set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2); Programovanie geofyziklnych loh v prostred MATLAB Zadanie: Natanie SRF gridu (bram.grd) a jeho zobrazenie vo forme

rznych plonch mp: a) vo forme vyplnench farebnch izoiar, b) vo forme farebnej image mapy, c) preklopenej mapy okolo diagonly taktie vo forme vyplnench izoiar a image. Skste tieto vetky mapy umiestni do jednho obrzku typu subplot a popte vetky osi (skutonmi hodnotami sradnc x a y) a nzvy samotnch obrzkov. pozn.: Mete pritom vyui u hotov skript read_srf_grid.m

Recently Viewed Presentations

  • AP Exam Review

    AP Exam Review

    No, you can't get credit for writing about your favorite Dr. Seuss book, as one daring but misguided student tried to do a few years ago. The College Board wants to evaluate how well you understand and write about ....
  • Assessing Intervention Fidelity in RCTs: Concepts and Methods

    Assessing Intervention Fidelity in RCTs: Concepts and Methods

    Assessing Intervention Fidelity in RCTs: Concepts and Methods Panelists: David S. Cordray, PhD Chris Hulleman, PhD Joy Lesnick, PhD Vanderbilt University Presentation for the IES Research Conference Washington, DC June 12, 2008 * * The C of Item and Scale...
  • Crimson® 3.1 Updates - Red Lion

    Crimson® 3.1 Updates - Red Lion

    Annonce par e-mail. Mercredi. Publications sur les réseaux sociaux, pour orienter le trafic vers le Web et les vidéos. 04-Feb-19. Principales nouveautés et améliorations. Protocole client OPC UA. Accès à l'historique OPC UA. Connecteur MQTT pour Google Cloud.
  • The Screech Owl Who Liked Television

    The Screech Owl Who Liked Television

    for years to come and are anxious to share it with anyone who will listen. Utter. Utter . is a multiple meaning word. It can also mean total, as in the sentence When the lights went out the city was...
  • Chapter 2

    Chapter 2

    The MARIE ISA consists of only thirteen instructions. 4.8 MARIE This is the format of a MARIE instruction: The fundamental MARIE instructions are: 4.8 MARIE This is a bit pattern for a LOAD instruction as it would appear in the...
  • Ocean Thermal Energy - Western Kentucky University

    Ocean Thermal Energy - Western Kentucky University

    For a 40 mW plant, a 10 meter wide intake pipe is needed. This is the size of a traffic tunnel. History of OTECs Jacques d 'Arsonval in 1881 first proposed the idea Completed by his student, Georges Claude in...
  • Introduction

    Introduction

    We evaluated the prevalence of central nervous system (CNS) defect, NTDs and encephalocele (which is considered separately in the registry as it may occur slightly after neural tube closure) in the Antiretroviral Pregnancy Registry by drug class and specified individual...
  • User Habits & Trends - An analysis of how TRICS is used

    User Habits & Trends - An analysis of how TRICS is used

    An Analysis of Multi-Modal Surveys at LIDL Food Stores. WAYNE SAYERS, DORSET COUNTY COUNCIL. In this presentation I am going to talk about some recent independently undertaken surveys at a selection of LIDL foodstores in England, that were input and...