⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matinterogator.m

📁 基于matlab的反演程序,用于地球物理勘探中射线追踪及偏移成像程序.
💻 M
📖 第 1 页 / 共 2 页
字号:
        set(hbut,'string',nm);
    end
end

% EXPOTING FILES 
%----------------
function ExportFiles(hObject, eventdata, handles)
h=get(gcf,'userdata');
hobj=gco;
hmsg=h{1};
StringInfo=['Saving Data To Disk'];
set(hmsg,'string',StringInfo,'backgroundcolor',[1 1 1]);
hexport=h{end};
dat=get(hexport,'userdata');
exporthandles=dat{4};
if(isempty(exporthandles))
    set(hmsg,'string','No Data to Export','backgroundcolor',[1 1 0]);
    return
end
exportnames=cell(length(exporthandles),1);
exportdata=cell(length(exporthandles),1);
for ii=1:length(exporthandles)
    dat=get(exporthandles(ii),'userdata');
    exportnames{ii}=get(dat(2),'string');
    udat=get(dat(4),'userdata');
    exportdata{ii}=udat{1};
end

checkwhich=get(hobj,'string');
if(strcmp(checkwhich,'Save'))
    % not exporting but saving files
    [file,path]=myuifile(gcf,'*.mat','Save File As','put');
    if(file==0)
        set(hmsg,'string','Action Canceled','backgroundcolor',[1 1 0]);
        return
    end
    if(isempty(findstr(file,'.mat')))
        file=[path file '.mat'];
    end
    dat=[];
    for ii=1:size(exportnames,1)
        xx=[exportnames{ii} '= exportdata{ii};'];
        eval(xx);
        dat=[dat ' ' exportnames{ii}];        
    end
    saveingdata=['save ' file dat];
    eval(saveingdata);
    stringinfo=['Data saved:  ' file];
    set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 1]);
else
    % this will close the figure so sticking all data in to the hexport handle allowing
    % the main program to export just the pertinant data
    dat=get(hexport,'userdata');
    dat{end}={exportnames exportdata};
    set(hexport,'userdata',dat);
    uiresume(gcf);
end

% HIGH LIGHT BUTTONS
%--------------------
function HighLightButton(hObject, eventdata, handles)
% This simply will get user data of check box clicked and set their background
% and foreground colour to something different
hdat=get(gcbo,'userdata');
val=get(hdat(1),'value');
h=get(gcf,'userdata');
hmsg=h{1};
hcheck=h{2};
hexport=h{end};
CheckExport=get(hexport,'userdata');
n1=CheckExport{2};
n2=CheckExport{3};
ExportDat=CheckExport{4};
CheckButton=find(hdat(1)==hcheck);
switch val
case 1
    if(ischar(n1))
    elseif(n2>=n1)
        % Checking to make sure that user is not over selecting number of files specified
        set(hmsg,'string',['Only ' num2str(n2) ' can be selected.'],'backgroundcolor',[1 0 1]);
        set(hdat(1),'value',0);
        return
    end
    set(hdat,'backgroundcolor',[1 .5 0]);
    set(hdat(1),'tooltipstring','Press To Un-Select Array');
    sel='Selected';
    ad=[1];
    ExportDat=[ExportDat;hdat(1)];
case 0
    col={[.7 .7 .7] [1 1 1]};
    if(((CheckButton/2)-round(CheckButton/2))==0)
        % remember that the first button saved in userdata is the hmsg
        jj=1;
    else
        jj=2;
    end
    set(hdat,'backgroundcolor',col{jj});
    set(hdat(1),'tooltipstring','Press To Select Array For Export');
    sel='Unselected';
    tg='';
    ad=[-1];
    kll=find(ExportDat==hdat(1));
    ExportDat(kll)=[];
end
StringInfo=['You have ' sel ' "' get(hdat(2),'string') '".'];
set(hmsg,'string',StringInfo,'backgroundcolor',[1 1 1]);
set(hexport,'userdata',{CheckExport{1} n1 n2+ad ExportDat {}});

% INSPECTING ARRAY
%------------------
function inspectarray(hcbo,eventdata)
h=get(gcf,'userdata');
hmsg=h{1};
hhandles=h{2};
masterfig=gcf;
hbut=gco;
udat=get(hbut,'userdata');
dat=udat{1};
if(strcmp(class(dat),'char'))
    qst=cell(1,size(dat,1));
    a=qst;
    flags=[];
    if(size(dat,1)>=2)
        for ii=1:size(dat,1)
            x=0;
            qst{ii}=['Character Array ' num2str(ii)];
            a{ii}=deblank(dat(ii,:));
            flags=[flags 0];
        end
    else
        qst={'Character Array: ' 'Change Class To: '};
        a={num2str(dat) 'String|Numeric';};
        flags=[1 1];        
    end
    set(hmsg,'string','Change Array Data','backgroundcolor',[1 1 1]);
    titlestr=['Type New Array Data'];
    ansout=askthingsle(masterfig,qst,a,flags,titlestr);
    if(size(ansout,2)==2)
        checkcl=ansout{2};
        checkans=ansout{1};
        switch checkcl
            case 'Numeric'
                ansout=str2double(checkans);
                if(isnan(ansout))
                    stringinfo='Answer Was Not Numeric';
                    set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 0]);
                    return
                end
            case 'String'
                ansout=ansout{1};
            otherwise
        end
    else
        if(isempty(ansout))
        else
            ans=[];
            for ii=1:size(ansout,2)
                ans=strmat(ans,ansout{ii});
            end
            ansout=ans;
        end
    end
elseif(strcmp(class(dat),'cell'))
    ansout=matinterogator(dat,100,'Inspection');
    ansout=ansout;
elseif(strcmp(class(dat),'struct'))
    ansout=matinterogator(dat,100,'Inspection');
    ansout=ansout;
else
    ansout='';
    if(length(dat)<=1)
        set(hmsg,'string','Change Array Data','backgroundcolor',[1 1 1]);
        qst={'Array Value: ' 'Change Class To: '};
        a={num2str(dat) 'Numeric|String'};
        flags=[1 0];
        titlestr=['Change Array Value'];
        ansout=askthingsle(masterfig,qst,a,flags,titlestr);
        if(isempty(ansout))
        else
            checkcl=ansout{2};
            checkans=ansout{1};
            switch checkcl
                case 'Numeric'
                    ansout=str2double(checkans);
                    if(isnan(ansout))
                        stringinfo='Answer Was Not Numeric';
                        set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 0]);
                        return
                    end
                case 'String'
                    ansout=ansout{1};
                otherwise
            end
        end
    else
        % this will cover all the class' associated with numbedrs; double,
        % single, int8, uint8, et
        stringinfo='Desired Plot Technique';
        set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 1]);
        butt=questdlg('Choose How To Plot','Chose Way For Array To Be Plotted',...
            'Stack Plot','Arranged Plot','Cancel','Cancel');
        switch butt;
            case 'Stack Plot'
                figure;
                set(gcf,'menubar','none');
                plot(dat);
                ansout={};
            case 'Arranged Plot'
                figure;
                set(gcf,'menubar','none');
                if(size(dat,1)>=size(dat,2))
                else
                    dat=dat';
                end
                plot([1:1:size(dat,2)],dat);
            case 'Cancel'
                stringinfo='Choose or Save Desired Files';
                set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 1]);
                return
            otherwise
                stringinfo='Choose or Save Desired Files';
                set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 1]);
                return
        end
        
    end
end

if(isempty(ansout))
    stringinfo='Choose or Save Desired Files';
    set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 1]);
else
    stringinfo='Array Has Been Changed';
    set(hmsg,'string',stringinfo,'backgroundcolor',[1 1 1]);
    hname=udat{2};
    hsize=udat{3};
    hclass=udat{4};
    sz=[num2str(size(ansout,1)) 'x' num2str(size(ansout,2))];
    set(hsize,'string',sz,'userdata',{ansout hname hsize hclass});
    cl=class(ansout);
    set(hclass,'string',cl,'userdata',{ansout hname hsize hclass});
    set(hname,'userdata',{ansout hname hsize hclass});
end

% CLOSING MATINTEROGATOR
%------------------------
function CloseMatInterogator(hcbo,eventdata)
try
    h=get(gcf,'userdata');
    hexport=h{end};
    dat=get(hexport,'userdata');
    dat{end}='';
    set(hexport,'userdata',dat);
    uiresume(gcf);
catch
    uiresume(gcf);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -