📄 siginputfig.m
字号:
disp('Z Callback not implemented yet.')
% --------------------------------------------------------------------
function varargout = depth_in_meters_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.depth_in_meters.
disp('depth_in_meters Callback not implemented yet.')
% --------------------------------------------------------------------
function varargout = pushbutton5_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton5.
global sigbody x y z dz
global phan
[filename, path] = uigetfile({'*.par','Intem3d.par (*.par)'},'Pick a file');
cd(path);
if exist('intem3d.par')
p={' ',' '};
p=buf2par(p,readtxt('intem3d.par'));
sig0=getpar(p,'double','sig0','','');
x=getpar(p,'double','x', '','');Nx=length(x);dx=x(2)-x(1);
y=getpar(p,'double','y', '','');Ny=length(y);dy=y(2)-y(1);
z=getpar(p,'double','z', '','');Nz=length(z);
dz=getpar(p,'double','dz', '','');
set(handles.X,'String',['X= ' num2str(x(1)) ':' num2str(dx) ':' num2str(x(Nx)) ' m']);
set(handles.Y,'String',['Y= ' num2str(y(1)) ':' num2str(dy) ':' num2str(y(Ny)) ' m']);
set(handles.Z,'String',['Z= ' num2str(z(1)) ':' num2str(z(Nz)) ' m']);
set(handles.depth_in_meters,'String',[num2str(z(str2double(get(handles.depth,'String')))) ' m']);
if exist('sigbody.dat')
load('sigbody.dat');
if (size(sigbody)==[1 1]) sigbody=sigbody*ones(Nx,Ny,Nz);
else sigbody=reshape(sigbody,Nx,Ny,Nz);
end;
else sigbody=zeros(Nx,Ny,Nz);
end;
map=colormap;
depth=str2double(get(handles.depth,'String'));
maxs=max(sigbody(:));
mins=min(sigbody(:));
axes(handles.sigma);
cla
for ik=1:Nx
for jk=1:Ny
phan(ik,jk)=patch([x(ik)+dx/2 x(ik)-dx/2 x(ik)-dx/2 x(ik)+dx/2],...
[y(jk)+dy/2 y(jk)+dy/2 y(jk)-dy/2 y(jk)-dy/2],'w');
if sigbody(ik,jk,depth)
if (maxs==mins) col=32;
else col=round(1+(sigbody(ik,jk,depth)-mins)*63/(maxs-mins));
end;
set(phan(ik,jk),'FaceColor',map(col,:));
end;
end;
end;
else
errordlg('File does not exist','Error');
end;
% --------------------------------------------------------------------
function varargout = pushbutton6_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton6.
global sigbody
global sigb
%saveasc('sigbody.dat',sigbody(:)+sigb(:));
saveasc('sigbody.dat',sigbody(:));
% READTXT read file into char buffer
% if no file, return empty
%
% buf= readtxt(in)
%
function buf=readtxt(in)
buf=[];
ff=fopen(in,'r');
if(ff==-1) return; end;
while 1
line = fgetl(ff);
if ~isstr(line), break, end
buf=[buf line sprintf('\n')];
end
fclose(ff);
return;
function buf=arg2buf(n,v)
buf=[];
for k=1:n
if(ischar(v{k}))
buf=[buf v{k} sprintf('\n')];
end
end
% convert character buffer
% to a structure array
%
function par=buf2par(par,buf)
if(isempty(par)) return; end;
lf=sprintf('\n');
ind=[];
if(isempty(buf)==0)
ind=find((buf==lf)|(buf==';'));
end
if(isempty(ind)==0) buf(ind)=' '; end;
ind=[1 ind length(buf)];
ii=size(par,1);
for k=1:length(ind)-1
str=buf(ind(k):ind(k+1));
in=min(find(str=='%'));
if(length(in)>0) str=str(1:in-1); end;
in=find(str=='=');
if(length(in)>0)
ii=ii+1;
par{ii,1}=delspace(str(1:in-1));
par{ii,2}=str(in+1:end);
end
end
return
function res=delspace(str)
in=find(str~=' ');
if(length(in)>0) res=str(in); end;
% Grabbing the parameter
% from the input buffer
%
%
function res=getpar(pars,kind,name,def,cmnt)
if(length(pars)==0)
disp(sprintf('%8s = %-12s %s',name,def,cmnt))
res=[];
else
in=min(find(strcmp(pars(:,1),name)));
res=char(pars(in,2));
end
if(isempty(res)) res=def; end;
if(isempty(res)) return; end;
switch(lower(kind))
case 'char'
if(ischar(res)==0) res=num2str(res); end;
case 'double'
if(ischar(res))
% colon conversion here
% vectors without colons are converted anyway by str2num
%
in=find(res==':');
inb=find( (res=='[')+(res==']') );
switch(length(in))
case 0
res=str2num(res);
return;
case 1
res(inb)=' ';
stp=1;
beg=str2num(res(1:in-1));
fin=str2num(res(in+1:end));
case 2
res(inb)=' ';
beg=str2num(res(1:in(1)-1));
stp=str2num(res((in(1)+1):(in(2)-1)));
fin=str2num(res((in(2)+1):end));
otherwise
disp(['Error in parameter ' name ' bad value ' res ]);
end
res=[ beg : stp : fin ];
end
end;
return;
% ----------------------------------------------------------------------------
function res=loadasc(from)
% loadasc - load in ascii format
%
%
in=fopen(from,'r');
line=fgetl(in); % determine the length
res=sscanf(line,'%g');
d2=length(res);
fseek(in,0,-1);
res=fscanf(in,'%g');
fclose(in);
l=length(res);
d1=round(l/d2);
if(d1*d2==l) res=reshape(res,d2,d1)'; end
return;
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over X.
%function X_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to X (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% ----------------------------------------------------------------------------
function saveasc(where,what,form)
% saveasc save in ascii format
%
%
if(exist('form')~=1) form='%g '; end;
dims=size(what);
switch(length(dims))
case 0
return;
case 2
d1=dims(1);
d2=dims(2);
otherwise
d1=prod(dims);
d2=1;
end
what=reshape(what,d1,d2);
in=fopen(where,'w+');
for k1=1:d1
fprintf(in,form,what(k1,:));
fprintf(in,'\n');
end
fclose(in);
return;
% ----------------------------------------------------------------------------
function sb = bgcond(h,sig,x,y,z)
% ----------------------------------------------
% Computing background conductivity in the mesh
% ----------------------------------------------
%
% h : vector of layer thicknesses, [] for halfspace
% sig : vector of layer conductivities
% x : vector of the x coordinates of the mesh
% y : vector of the y coordinates of the mesh
% z : vector of the z coordinates of the mesh
% sb : Nxyz,1 vector of background conductivity
h = (h(:))';
Nx=length(x); Ny=length(y); Nz=length(z);
Nxyz=Nx*Ny*Nz;
nl = length(sig);
h=[0 h inf];
zbnd=zeros(1,length(h));
zbnd(1)=h(1);
for i=2:length(h)
zbnd(i)=zbnd(i-1)+h(i);
end
sb = zeros(0,1);
for i=1:nl
ind = find((z>zbnd(i)) & (z<zbnd(i+1)));
numc=length(ind)*Nx*Ny;
sb=[sb;sig(i)*ones(numc,1)];
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -