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

📄 editparameter.m

📁 一共有15个m文件
💻 M
📖 第 1 页 / 共 2 页
字号:
        ['EditParameter(''NextButton_Callback'',gcbo)'] } ;

ButtonWidth = 80 ;
ButtonHeight = 25 ;
ButtonXPos = FigureWidth - ButtonWidth * 4 - TabSpace * 6 ;
ButtonYPos = TabSpace * 2 ;;
ButtonPosition = [ButtonXPos  ButtonYPos  ButtonWidth  ButtonHeight] ;
for num = 1: 4
    TempButtonPosition = ButtonPosition ;
    TempButtonPosition(1) = TempButtonPosition(1) + (num - 1) * (ButtonWidth + TabSpace) ;
    % generate the pushbutton: OK .
    ButtonHandle = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', TempButtonPosition, ...
        'Style', 'pushbutton', 'Tag',ButtonTag{num}, 'string', ButtonString{num}, 'Fontsize',12, ...
        'Callback', ButtonCallback{num} ) ;
    
end


handles = guihandles( FigureHandle ) ;
guidata( FigureHandle, handles ) ;




% --------------------------------------------------------------------------
function  init_FigureContent( h )
       
handles = guidata( h ) ;


% get the ArcSimulationData .
ArcSimulationData = getappdata( handles.EditParameter, 'ArcSimulationData' ) ;
if isempty( ArcSimulationData )
    ArcSimulationData = ArcSimulationSoft( 'Get_DefaultArcSimulationData' ) ;    
    % save the data .
    setappdata( handles.EditParameter, 'ArcSimulationData', ArcSimulationData ) ;
end


TagIndex = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;

% define the string of the MainCircuitParameterText .
Text1String = { 'L21'; 'L22'; 'M1'; 'M2'; 'R21'; 'R22'; ...
        'R1'; 'L1'; 'C'; 'ea'; 'eb'; 'ec' } ;
ParameterName = { 'L21'; 'L22'; 'M1'; 'M2'; 'R21'; 'R22'; ...
        'R1'; 'L1'; 'C'; 'ea'; 'eb'; 'ec' } ;
for num = 1: 12
    % get the handle of the text .
    TextHandle = getfield( handles, ['MainCircuitParameterText', TagIndex(num)] ) ;
    EditHandle = getfield( handles, ['MainCircuitParameterEdit', TagIndex(num)] ) ;
    
    set( TextHandle, 'String', Text1String{num} ) ;    
    
    % get the handle of the edit .
    ParameterValue = getfield( ArcSimulationData.MainCircuitParameter, ParameterName{num} ) ;
    set( EditHandle, 'String', num2str( ParameterValue ) ) ;    
    
    
end


% define the string of the ArcResistanceParameterText .
Text2String = { 'A'; 'B'; 'C'; 'D'; 'L'; 'ω'; 'θ' } ;
ParameterName = { 'A'; 'B'; 'C'; 'D'; 'L'; 'Angle1'; 'Angle2' } ; ;
for num = 1: 7
    % get the handle of the text .
    TextHandle = getfield( handles, ['ArcResistanceParameterText', TagIndex(num)] ) ;
    EditHandle = getfield( handles, ['ArcResistanceParameterEdit', TagIndex(num)] ) ;
    
    set( TextHandle, 'String', Text2String{num} ) ;    
    
    % get the handle of the edit .
    ParameterValue = getfield( ArcSimulationData.ArcResistanceParameter, ParameterName{num} ) ;
    set( EditHandle, 'String', num2str( ParameterValue ) ) ;    
    
end





% --------------------------------------------------------------------------
function  MainCircuitParameter_Callback( h )
       
handles = guidata( h ) ;


% get the ArcSimulationData .
ArcSimulationData = getappdata( handles.EditParameter, 'ArcSimulationData' ) ;

% define the string of the MainCircuitParameterText .
Text1String = { 'L21'; 'L22'; 'M1'; 'M2'; 'R21'; 'R22'; ...
        'R1'; 'L1'; 'C'; 'ea'; 'eb'; 'ec' } ;
ParameterName = { 'L21'; 'L22'; 'M1'; 'M2'; 'R21'; 'R22'; ...
        'R1'; 'L1'; 'C'; 'ea'; 'eb'; 'ec' } ;

TagIndex = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;

% get the tag and the string of the edit .
EditTag = get( h, 'Tag' ) ;
EditIndex = findstr( TagIndex, EditTag(end) ) ;

EditValue = get( h, 'String' ) ;
EditValue = str2num( EditValue ) ;
if isempty( EditValue )
    warndlg( '请输入一个数字。', '警告' ) ;
    return ;
end

% 保存结果。
% ---------------------------------------------------
ArcSimulationData.MainCircuitParameter = setfield( ...
    ArcSimulationData.MainCircuitParameter, ParameterName{EditIndex}, EditValue ) ;


% 检查输入参数,保证不能被0除。
% ----------------------------------------------------
L21 = ArcSimulationData.MainCircuitParameter.L21 ;
L22 = ArcSimulationData.MainCircuitParameter.L22 ;
M1 = ArcSimulationData.MainCircuitParameter.M1 ;
M2 = ArcSimulationData.MainCircuitParameter.M2 ;

if L21 == M2
    warndlg( { 'L21 不能等于 M2,'; '因为(L21 - M2)将作为除数。' } , '警告' ) ;
    return ;
    
elseif (2 * (L21 - M2) + L22  - 2 * M1 + M2 ) == 0
    warndlg( { '(2 * (L21 - M2) + L22  - 2 * M1 + M2 ) 不能等于 0,'; ...
            '因为(2 * (L21 - M2) + L22  - 2 * M1 + M2 )将作为除数。' } , '警告' ) ;
    return ;
    
elseif ArcSimulationData.MainCircuitParameter.C == 0
    warndlg( 'C 不能等于 0 。', '警告' ) ;
    return ;
    
else
end


% save the data .
setappdata( handles.EditParameter, 'ArcSimulationData', ArcSimulationData ) ;






% --------------------------------------------------------------------------
function  ArcResistanceParameter_Callback( h )
       
handles = guidata( h ) ;


% get the ArcSimulationData .
ArcSimulationData = getappdata( handles.EditParameter, 'ArcSimulationData' ) ;

% define the string of the ArcResistanceParameterText .
Text2String = { 'A'; 'B'; 'C'; 'D'; 'L'; 'ω'; 'θ' } ;
ParameterName = { 'A'; 'B'; 'C'; 'D'; 'L'; 'Angle1'; 'Angle2' } ; ;

TagIndex = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;


% get the tag and the string of the edit .
EditTag = get( h, 'Tag' ) ;
EditIndex = findstr( TagIndex, EditTag(end) ) ;

EditValue = get( h, 'String' ) ;
EditValue = str2num( EditValue ) ;
if isempty( EditValue )
    warndlg( '请输入一个数字。', '警告' ) ;
    return ;
end

ArcSimulationData.ArcResistanceParameter = setfield( ...
    ArcSimulationData.ArcResistanceParameter, ParameterName{EditIndex}, EditValue ) ;

% save the data .
setappdata( handles.EditParameter, 'ArcSimulationData', ArcSimulationData ) ;





% --------------------------------------------------------------------------
function  MainCircuitFormula_Callback( h )
       
handles = guidata( h ) ;


% get the ArcSimulationData .
% ArcSimulationData = getappdata( handles.StatusEquation, 'ArcSimulationData' ) ;
ArcSimulationData = getappdata( gcbf, 'ArcSimulationData' ) ;

DisplayStatusEquation( ArcSimulationData ) ;




% --------------------------------------------------------------------------
function  ArcResistanceFormula_Callback( h )
       
handles = guidata( h ) ;


% find if have the same figure, and close it .
OldFigure = findobj( 'type', 'figure', 'Tag', 'ArcResistanceFormula' ) ;
if ishandle( OldFigure )
    close( OldFigure ) ;
end

% init the variables .
FigureWidth = 500 ;
FigureHeight = 150 ;
TabSpace = 10 ;
TextHeight = 20 ;

% generate a new figure .
FigureHandle = figure( 'Visible', 'off' ) ;
set( FigureHandle, 'Units' , 'pixels', 'Position', [150  150  FigureWidth  FigureHeight], ...
    'Name', '电弧电阻公式', 'Tag', 'ArcResistanceFormula', 'FileName' , '' ,...
    'MenuBar' , 'none', 'NumberTitle' , 'off' ,...
    'Resize', 'off', 'windowstyle', 'normal', 'Visible', 'off' ) ;
movegui( FigureHandle, 'center' )

% get the color of the figure .
FigureColor = get( FigureHandle, 'Color' ) ;
% reset the default value of the uicontrols .
set(FigureHandle,'defaultuicontrolunits','normalized');
set(FigureHandle,'defaultuicontrolfontname','隶书');
set(FigureHandle,'defaultuicontrolBackgroundColor', FigureColor );


% generate the parameters of the MainCircuitParameter .
% -----------------------------------------------------------------------------
% define the first frame .
FrameXPos = TabSpace * 2 ;
FrameWidth = FigureWidth - TabSpace * 4  ;
FrameHeight = 70 ;
FrameYPos = FigureHeight - FrameHeight - TabSpace * 2 ;
Frame1Position = [FrameXPos  FrameYPos  FrameWidth  FrameHeight] ;
% generate a frame .
TitleHandle = uicontrol(FigureHandle,'style','frame', 'Units','pixels',...
    'position',Frame1Position  );


TextXPos = Frame1Position(1) + TabSpace * 1.5 ;
TextYPos = Frame1Position(2) + Frame1Position(4) - TextHeight - TabSpace ;
TextWidth = Frame1Position(3) - TabSpace * 3 ;
TextPosition = [TextXPos  TextYPos  TextWidth  TextHeight] ;
% subtitle: 电弧电阻公式
TextHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
    'position',TextPosition,'Horizontal','left',...
    'string', '电弧电阻公式:', 'fontsize',13 );

TextXPos = Frame1Position(1) + TabSpace * 1.5 ;
TextYPos = TextPosition(2) - TextHeight - TabSpace ;
TextWidth = Frame1Position(3) - TabSpace * 3 ;
TextPosition = [TextXPos  TextYPos  TextWidth  TextHeight] ;
% subtitle: 电弧电阻公式
TextHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
    'position',TextPosition,'Horizontal','center',...
    'string', 'R(t)=C*L*exp{1/[A+B(1-cos(2ωt+θ+D))]}', 'fontsize',13 );



ButtonWidth = 80 ;
ButtonHeight = 25 ;
ButtonXPos = FigureWidth - ButtonWidth - TabSpace * 2 ;
ButtonYPos = TabSpace * 2 ;;
ButtonPosition = [ButtonXPos  ButtonYPos  ButtonWidth  ButtonHeight] ;
% generate the pushbutton: Close .
ButtonHandle = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', ButtonPosition, ...
    'Style', 'pushbutton', 'string', '关闭', 'Fontsize',12, 'Callback', ['close(gcbf) ;'] ) ;

% display the figure .
set( FigureHandle, 'Visible', 'on' ) ;






% --------------------------------------------------------------------------
function  LoadData_Callback( h )
       
handles = guidata( h ) ;


PromptString = '选择数据文件.' ;
WarningString1 = '文件格式出错。 ' ;
WarningString2 = '选择的文件不是正确的数据文件。 ' ;


[ FileName , PathName ] = uigetfile( {'*.mat','数据文件(*.mat)'}, PromptString ) ;


if FileName == 0
    return ;    
else
    
    [TempPathName, FileName, FileTypeName, Version] = fileparts( FileName ) ;

    if ~strcmp( FileTypeName, '.mat' ) ;
        warndlg( WarningString1, '警告', 'modal' ) ;
        return ;
    end
    SaveFile = fullfile( PathName, [FileName, FileTypeName, Version] ) ;
end

ArcSimulationData = [] ;
try
    load( SaveFile, 'ArcSimulationData' ) ;
catch
end

if isempty( ArcSimulationData ) | ~isstruct( ArcSimulationData ) ...
        | ~isfield( ArcSimulationData, 'MainCircuitParameter' ) ...
        | ~isfield( ArcSimulationData, 'ArcResistanceParameter' ) 
    
    warndlg( WarningString1, '警告', 'modal' ) ;
    return ;
end


% save the data .
setappdata( handles.EditParameter, 'ArcSimulationData', ArcSimulationData ) ;

% display the new data .
init_FigureContent( h ) ;


% --------------------------------------------------------------------------
function  SaveData_Callback( h )
       
handles = guidata( h ) ;

% get the ArcSimulationData .
ArcSimulationData = getappdata( handles.EditParameter, 'ArcSimulationData' ) ;


PromptString = '保存数据文件.' ;
MessageString = '保存数据文件成功。 ' ;

[ FileName , PathName ] = uiputfile( {'*.mat','数据文件(*.mat)'}, PromptString ) ;


if FileName == 0
    return ;    
else
    
    [TempPathName, FileName, FileTypeName, Version] = fileparts( FileName ) ;

    if ~strcmp( FileTypeName, '.mat' ) ;
        FileTypeName = '.mat' ;
    else
    end
    SaveFile = fullfile( PathName, [FileName, FileTypeName, Version] ) ;
end


if strcmp( lower( FileName ), 'imagedata' ) ;
    warndlg( '不能覆盖系统文件:ImageData.mat。', '警告', 'modal' ) ;
    return ;    
end


% save the result  file .
save( SaveFile, 'ArcSimulationData' ) ;


msgbox( MessageString ) ;




% --------------------------------------------------------------------------
function  PreviousButton_Callback( h )
       
handles = guidata( h ) ;

% get the ArcSimulationData .
ArcSimulationData = getappdata( handles.EditParameter, 'ArcSimulationData' ) ;

% return the wizard figure .
% ArcSimulationSoft( ArcSimulationData ) ;
CalculateStatusEquation( ArcSimulationData ) ;


% close the current figure .
pause(0) ;
close( handles.EditParameter ) ;


% --------------------------------------------------------------------------
function  NextButton_Callback( h )
       
handles = guidata( h ) ;

% get the ArcSimulationData .
ArcSimulationData = getappdata( handles.EditParameter, 'ArcSimulationData' ) ;


SimulateFigure( ArcSimulationData ) ;


% close the current figure .
pause(0) ;
close( handles.EditParameter ) ;

⌨️ 快捷键说明

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